您的位置:首页 > 运维架构 > Linux

CentOS7.0 LAMP环境搭建

2015-02-03 17:12 351 查看
最近参加了HPconf大会,抽中了UCloud的云主机使用券,试用期为一个月,操作系统为CentOS 7.0版本,然后在上面搭建了LAMP环境,主要是用来做实验用。

;-)
[root@10-4-23-28 ~]# yum -y install httpd
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.8-3.el7.x86_64                            1/5
Installing : apr-util-1.5.2-6.el7.x86_64                       2/5
Installing : httpd-tools-2.4.6-18.el7.centos.x86_64            3/5
Installing : mailcap-2.1.41-2.el7.noarch                       4/5
Installing : httpd-2.4.6-18.el7.centos.x86_64                  5/5
Verifying  : mailcap-2.1.41-2.el7.noarch                       1/5
Verifying  : httpd-tools-2.4.6-18.el7.centos.x86_64            2/5
Verifying  : apr-util-1.5.2-6.el7.x86_64                       3/5
Verifying  : apr-1.4.8-3.el7.x86_64                            4/5
Verifying  : httpd-2.4.6-18.el7.centos.x86_64                  5/5
Installed:
httpd.x86_64 0:2.4.6-18.el7.centos
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7                       apr-util.x86_64 0:1.5.2-6.el7
httpd-tools.x86_64 0:2.4.6-18.el7.centos       mailcap.noarch 0:2.1.41-2.el7


[root@10-4-23-28 ~]# yum -y install mariadb mariadb-server
[root@10-4-23-28 ~]# cp /usr/share/mysql/my-small.cnf /etc/my.cnf

[root@10-4-23-28 ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!


[root@10-4-23-28 ~]# yum install php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.4.16-23.el7_0.3 will be installed
--> Processing Dependency: php-common(x86-64) = 5.4.16-23.el7_0.3 for package: php-5.4.16-23.el7_0.3.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.4.16-23.el7_0.3 for package: php-5.4.16-23.el7_0.3.x86_64
--> Running transaction check
---> Package php-cli.x86_64 0:5.4.16-23.el7_0.3 will be installed
---> Package php-common.x86_64 0:5.4.16-23.el7_0.3 will be installed
--> Processing Dependency: libzip.so.2()(64bit) for package: php-common-5.4.16-23.el7_0.3.x86_64
--> Running transaction check
---> Package libzip.x86_64 0:0.10.1-8.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================
Package               Arch              Version                       Repository          Size
================================================================================================
Installing:
php                   x86_64            5.4.16-23.el7_0.3             updates            1.3 M
Installing for dependencies:
libzip                x86_64            0.10.1-8.el7                  base                48 k
php-cli               x86_64            5.4.16-23.el7_0.3             updates            2.7 M
php-common            x86_64            5.4.16-23.el7_0.3             updates            561 k
Transaction Summary
================================================================================================
Install  1 Package (+3 Dependent packages)
Total download size: 4.7 M
Installed size: 17 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): libzip-0.10.1-8.el7.x86_64.rpm                                    |  48 kB  00:00:00
(2/4): php-cli-5.4.16-23.el7_0.3.x86_64.rpm                              | 2.7 MB  00:00:00
(3/4): php-common-5.4.16-23.el7_0.3.x86_64.rpm                           | 561 kB  00:00:00
(4/4): php-5.4.16-23.el7_0.3.x86_64.rpm                                  | 1.3 MB  00:00:01
------------------------------------------------------------------------------------------------
Total                                                           2.5 MB/s | 4.7 MB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libzip-0.10.1-8.el7.x86_64                                                   1/4
Installing : php-common-5.4.16-23.el7_0.3.x86_64                                          2/4
Installing : php-cli-5.4.16-23.el7_0.3.x86_64                                             3/4
Installing : php-5.4.16-23.el7_0.3.x86_64                                                 4/4
Verifying  : php-cli-5.4.16-23.el7_0.3.x86_64                                             1/4
Verifying  : php-common-5.4.16-23.el7_0.3.x86_64                                          2/4
Verifying  : libzip-0.10.1-8.el7.x86_64                                                   3/4
Verifying  : php-5.4.16-23.el7_0.3.x86_64                                                 4/4
Installed:
php.x86_64 0:5.4.16-23.el7_0.3
Dependency Installed:
libzip.x86_64 0:0.10.1-8.el7                     php-cli.x86_64 0:5.4.16-23.el7_0.3
php-common.x86_64 0:5.4.16-23.el7_0.3
Complete!
[root@10-4-23-28 ~]# yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package php-common-5.4.16-23.el7_0.3.x86_64 already installed and latest version
Resolving Dependencies

--> Finished Dependency Resolution

Total download size: 4.0 M
Installed size: 13 M
Is this ok [y/d/N]: y
Downloading packages:
(1/25): libX11-1.6.0-2.1.el7.x86_64.rpm                                  | 605 kB  00:00:00
(2/25): libXau-1.0.8-2.1.el7.x86_64.rpm                                  |  29 kB  00:00:00
(3/25): libXpm-3.5.10-5.1.el7.x86_64.rpm                                 |  52 kB  00:00:00
(4/25): libjpeg-turbo-1.2.90-5.el7.x86_64.rpm                            | 134 kB  00:00:00
(5/25): libjpeg-turbo-devel-1.2.90-5.el7.x86_64.rpm                      |  98 kB  00:00:00
(6/25): libjpeg-turbo-static-1.2.90-5.el7.x86_64.rpm                     | 120 kB  00:00:00
(7/25): libjpeg-turbo-utils-1.2.90-5.el7.x86_64.rpm                      |  76 kB  00:00:00
(8/25): libpng-1.5.13-5.el7.x86_64.rpm                                   | 212 kB  00:00:00
(9/25): libtool-ltdl-2.4.2-20.el7.x86_64.rpm                             |  49 kB  00:00:00
(10/25): libxcb-1.9-5.el7.x86_64.rpm                                     | 169 kB  00:00:00
(11/25): libxslt-1.1.28-5.el7.x86_64.rpm                                 | 242 kB  00:00:00
(12/25): php-gd-5.4.16-23.el7_0.3.x86_64.rpm                             | 124 kB  00:00:00
(13/25): php-ldap-5.4.16-23.el7_0.3.x86_64.rpm                           |  49 kB  00:00:00
(14/25): php-mbstring-5.4.16-23.el7_0.3.x86_64.rpm                       | 501 kB  00:00:00
(15/25): php-mysql-5.4.16-23.el7_0.3.x86_64.rpm                          |  97 kB  00:00:00
(16/25): php-odbc-5.4.16-23.el7_0.3.x86_64.rpm                           |  62 kB  00:00:00
(17/25): php-pdo-5.4.16-23.el7_0.3.x86_64.rpm                            |  95 kB  00:00:00
(18/25): php-process-5.4.16-23.el7_0.3.x86_64.rpm                        |  52 kB  00:00:00
(19/25): php-xml-5.4.16-23.el7_0.3.x86_64.rpm                            | 122 kB  00:00:00
(20/25): php-xmlrpc-5.4.16-23.el7_0.3.x86_64.rpm                         |  64 kB  00:00:00
(21/25): php-pear-1.9.4-21.el7.noarch.rpm                                | 357 kB  00:00:00
(22/25): t1lib-5.1.2-14.el7.x86_64.rpm                                   | 166 kB  00:00:00
(23/25): unixODBC-2.3.1-10.el7.x86_64.rpm                                | 413 kB  00:00:00
(24/25): libX11-common-1.6.0-2.1.el7.noarch.rpm                          | 181 kB  00:00:03
(25/25): php-bcmath-5.4.16-23.el7_0.3.x86_64.rpm                         |  54 kB  00:00:02
------------------------------------------------------------------------------------------------
Total                                                           1.2 MB/s | 4.0 MB  00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libjpeg-turbo-1.2.90-5.el7.x86_64                                           1/25
Installing : php-pdo-5.4.16-23.el7_0.3.x86_64                                            2/25
Installing : libjpeg-turbo-devel-1.2.90-5.el7.x86_64                                     3/25
Installing : php-process-5.4.16-23.el7_0.3.x86_64                                        4/25
Installing : libXau-1.0.8-2.1.el7.x86_64                                                 5/25
Installing : libxcb-1.9-5.el7.x86_64                                                     6/25
Installing : libxslt-1.1.28-5.el7.x86_64                                                 7/25
Installing : php-xml-5.4.16-23.el7_0.3.x86_64                                            8/25
Installing : 2:libpng-1.5.13-5.el7.x86_64                                                9/25
Installing : libtool-ltdl-2.4.2-20.el7.x86_64                                           10/25
Installing : unixODBC-2.3.1-10.el7.x86_64                                               11/25
Installing : libX11-common-1.6.0-2.1.el7.noarch                                         12/25
Installing : libX11-1.6.0-2.1.el7.x86_64                                                13/25
Installing : libXpm-3.5.10-5.1.el7.x86_64                                               14/25
Installing : t1lib-5.1.2-14.el7.x86_64                                                  15/25
Installing : php-gd-5.4.16-23.el7_0.3.x86_64                                            16/25
Installing : php-odbc-5.4.16-23.el7_0.3.x86_64                                          17/25
Installing : 1:php-pear-1.9.4-21.el7.noarch                                             18/25
Installing : libjpeg-turbo-static-1.2.90-5.el7.x86_64                                   19/25
Installing : php-mysql-5.4.16-23.el7_0.3.x86_64                                         20/25
Installing : libjpeg-turbo-utils-1.2.90-5.el7.x86_64                                    21/25
Installing : php-bcmath-5.4.16-23.el7_0.3.x86_64                                        22/25
Installing : php-mbstring-5.4.16-23.el7_0.3.x86_64                                      23/25
Installing : php-ldap-5.4.16-23.el7_0.3.x86_64                                          24/25
Installing : php-xmlrpc-5.4.16-23.el7_0.3.x86_64                                        25/25
Verifying  : php-xmlrpc-5.4.16-23.el7_0.3.x86_64                                         1/25
Verifying  : libjpeg-turbo-static-1.2.90-5.el7.x86_64                                    2/25
Verifying  : libjpeg-turbo-1.2.90-5.el7.x86_64                                           3/25
Verifying  : libX11-common-1.6.0-2.1.el7.noarch                                          4/25
Verifying  : libtool-ltdl-2.4.2-20.el7.x86_64                                            5/25
Verifying  : php-gd-5.4.16-23.el7_0.3.x86_64                                             6/25
Verifying  : libXpm-3.5.10-5.1.el7.x86_64                                                7/25
Verifying  : php-ldap-5.4.16-23.el7_0.3.x86_64                                           8/25
Verifying  : php-mbstring-5.4.16-23.el7_0.3.x86_64                                       9/25
Verifying  : libjpeg-turbo-devel-1.2.90-5.el7.x86_64                                    10/25
Verifying  : 2:libpng-1.5.13-5.el7.x86_64                                               11/25
Verifying  : php-xml-5.4.16-23.el7_0.3.x86_64                                           12/25
Verifying  : php-mysql-5.4.16-23.el7_0.3.x86_64                                         13/25
Verifying  : libxcb-1.9-5.el7.x86_64                                                    14/25
Verifying  : t1lib-5.1.2-14.el7.x86_64                                                  15/25
Verifying  : libxslt-1.1.28-5.el7.x86_64                                                16/25
Verifying  : unixODBC-2.3.1-10.el7.x86_64                                               17/25
Verifying  : php-odbc-5.4.16-23.el7_0.3.x86_64                                          18/25
Verifying  : libX11-1.6.0-2.1.el7.x86_64                                                19/25
Verifying  : php-pdo-5.4.16-23.el7_0.3.x86_64                                           20/25
Verifying  : libjpeg-turbo-utils-1.2.90-5.el7.x86_64                                    21/25
Verifying  : libXau-1.0.8-2.1.el7.x86_64                                                22/25
Verifying  : php-process-5.4.16-23.el7_0.3.x86_64                                       23/25
Verifying  : php-bcmath-5.4.16-23.el7_0.3.x86_64                                        24/25
Verifying  : 1:php-pear-1.9.4-21.el7.noarch                                             25/25
Installed:
libjpeg-turbo.x86_64 0:1.2.90-5.el7             libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7
libjpeg-turbo-static.x86_64 0:1.2.90-5.el7      libjpeg-turbo-utils.x86_64 0:1.2.90-5.el7
php-bcmath.x86_64 0:5.4.16-23.el7_0.3           php-gd.x86_64 0:5.4.16-23.el7_0.3
php-ldap.x86_64 0:5.4.16-23.el7_0.3             php-mbstring.x86_64 0:5.4.16-23.el7_0.3
php-mysql.x86_64 0:5.4.16-23.el7_0.3            php-odbc.x86_64 0:5.4.16-23.el7_0.3
php-pear.noarch 1:1.9.4-21.el7                  php-xml.x86_64 0:5.4.16-23.el7_0.3
php-xmlrpc.x86_64 0:5.4.16-23.el7_0.3
Dependency Installed:
libX11.x86_64 0:1.6.0-2.1.el7                libX11-common.noarch 0:1.6.0-2.1.el7
libXau.x86_64 0:1.0.8-2.1.el7                libXpm.x86_64 0:3.5.10-5.1.el7
libpng.x86_64 2:1.5.13-5.el7                 libtool-ltdl.x86_64 0:2.4.2-20.el7
libxcb.x86_64 0:1.9-5.el7                    libxslt.x86_64 0:1.1.28-5.el7
php-pdo.x86_64 0:5.4.16-23.el7_0.3           php-process.x86_64 0:5.4.16-23.el7_0.3
t1lib.x86_64 0:5.1.2-14.el7                  unixODBC.x86_64 0:2.3.1-10.el7
Complete!


[root@10-4-23-28 ~]# vi /etc/httpd/conf/httpd.conf
[root@10-4-23-28 ~]# vim !$
vim /etc/httpd/conf/httpd.conf
ServerSignature On #添加,在错误页中显示Apache的版本,Off为不显示
Options Indexes FollowSymLinks #修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)
#AddHandler cgi-script .cgi #修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)
AllowOverride None  #修改为:AllowOverride All (允许.htaccess)
AddDefaultCharset UTF-8 #修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码)
#Options Indexes FollowSymLinks #修改为 Options FollowSymLinks(不在浏览器上显示树状目录结构)
DirectoryIndex index.html #修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php(设置默认首页文件,增加index.php)
MaxKeepAliveRequests 500 #添加MaxKeepAliveRequests 500 (增加同时连接数)
[root@10-4-23-28 ~]# rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #删除默认测试页


[root@10-4-23-28 ~]# vi /etc/php.ini
[root@10-4-23-28 ~]# alias vi='vim'
[root@10-4-23-28 ~]# vi /etc/php.ini
date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
expose_php = Off
short_open_tag = On
open_basedir = .:/tmp
[root@10-4-23-28 ~]# systemctl restart mariadb.service
[root@10-4-23-28 ~]# systemctl restart httpd.service
[root@10-4-23-28 ~]# cd /var/www/html/
[root@10-4-23-28 html]# ls
[root@10-4-23-28 html]# vi index.php
[root@10-4-23-28 html]#


本文出自 “固态U盘” 博客,请务必保留此出处http://lavenliu.blog.51cto.com/5060944/1611196
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: