1, configure the firewall, open 80 ports, 3306 ports
Vi/etc/sysconfig/iptables
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
: wq! #保存退出 the firewall configuration file after the rule is added as shown:
/etc/init.d/iptables Restart #重启防火墙使配置生效
2. Turn off SELinux
Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
: wq! #保存退出 the SELinux configuration file as shown:
System operation and maintenance www.111cn.net warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
3, add third party yum source CentOS default yum source software version is too low, to install the latest version of Lamp,
This uses the third-party yum source wget http://www.atomicorp.com/installers/atomic #下载,
First install the wget command with the default yum source yum install wget
Sh./atomic #安装
Yum Clean all #清除当前yum缓存
Yum Makecache #缓存yum源中的软件包信息
Yum Repolist #列出yum源中可用的软件包
Installation article:
Installation of Apache Yum install httpd
#根据提示, enter y installation to install successfully
/ETC/INIT.D/HTTPD Start #启动Apache
Note: Apache will prompt for errors after booting:
Httpd:httpd:Could not reliably determine the server's fully qualif domain name, using:: 1 for ServerName
Workaround: vi/etc/httpd/conf/httpd.conf
#编辑 ServerName www.example.com:80 #去掉前面的注释: wq! #保存退出
Chkconfig httpd on #设为开机启动
/ETC/INIT.D/HTTPD Restart #重启Apache
Second, install MySQL
1, install MySQL yum installed MySQL mysql-server #询问是否要安装, enter Y can be installed automatically until the installation is complete
/etc/init.d/mysqld Start #启动MySQL
Chkconfig mysqld on #设为开机启动 cp/usr/share/mysql/my-medium.cnf/etc/my.cnf #拷贝配置文件 (Note: If the/etc directory has a my.cnf by default, you can overwrite it directly)
2, set the password for the root account mysql_secure_installation enter, according to the prompt input y enter 2 times password, enter according to the prompt input y last appearance: Thanks for using mysql! MySQL password setup is complete, restart MySQL:
/etc/init.d/mysqld Restart #重启
/etc/init.d/mysqld Stop #停止
/etc/init.d/mysqld Start #启动
Third, install PHP
1. Installing PHP yum install PHP #根据提示输入Y直到安装完成
2, install PHP components, so that PHP support MySQL yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-m bstring php-mcrypt Php-bcmath Php-mhash libmcrypt
Select the above installation package here to install according to the prompt input y enter
/etc/init.d/mysqld Restart #重启MySql
/ETC/INIT.D/HTTPD Restart #重启Apche
Configuration article one, Apache configuration
Vi/etc/httpd/conf/httpd.conf #编辑文件
Servertokens OS is modified to: Servertokens Prod (does not display the name of the server operating system when the error page appears) in line 44
Serversignature on 536 line modified to: Serversignature OFF (the Apache version is not shown in the error page)
Options Indexes FollowSymLinks on line 331 modified to: Options includes execcgi followsymlinks (allows server to execute CGI and SSI, prohibit listing of directories)
(www.111cn.net) #AddHandler cgi-script. CGI is modified in 796 lines to: AddHandler cgi-script. cgi. PL (allows CGI scripts with extension. pl to run)
AllowOverride None in line 338 is modified to: allowoverride all (Allow. htaccess)
Adddefaultcharset UTF-8 in 759 rows modified to: Adddefaultcharset GB2312 (add GB2312 as default encoding)
Options Indexes multiviews followsymlinks in 554 rows modified to Options multiviews followsymlinks (does not display the tree structure on the browser)
DirectoryIndex index.html Index.html.var in 402 line modified to: DirectoryIndex index.html index.htm default.html default.htm INDEX.P HP default.php Index.html.var (set default home file, add index.php)
KeepAlive OFF on line 76 modified to: KeepAlive on (allow program online)
Maxkeepaliverequests 100 in 83 rows modified to: Maxkeepaliverequests 1000 (increase number of simultaneous connections)
: wq! #保存退出
/ETC/INIT.D/HTTPD Restart #重启
Rm-f/etc/httpd/conf.d/welcome.conf/var/www/error/noindex.html #删除默认测试页
Second, PHP configuration
Vi/etc/php.ini #编辑
Date.timezone = PRC #在946行 Remove the preceding semicolon and change to 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
#在386行 lists the functions that PHP can disable, and if some programs need to use this function, you can delete and cancel the disabled.
expose_php = Off #在432行 Suppress the PHP version information
MAGIC_QUOTES_GPC = on #在745行 open MAGIC_QUOTES_GPC to prevent SQL injection
Short_open_tag = on #在229行支持php短标签
Open_basedir =.:/ tmp/#在380行 settings to allow access to the current directory (that is, the php script file directory) and/tmp/directory, you can prevent the PHP Trojan cross-site, if you change the installation program after the problem (for example: Dream Content Management System), you can log off this line, or directly write the program directory/data/ www.111cn.net/:/tmp/: wq! #保存退出
/etc/init.d/mysqld Restart #重启MySql
/ETC/INIT.D/HTTPD Restart #重启Apche
System operation and maintenance www.111cn.net warm reminder: qihang01 original Content © Copyright, reproduced please indicate the source and the original chain
Test Article cd/var/www/html
VI index.php #输入下面内容
<?php
Phpinfo ();
?>
: wq! #保存退出
In the client browser enter the server IP address, you can see the configuration information as shown in the relevant!
NOTE: The Apache default program directory is/var/www/html
Permission settings: Chown apache.apache-r/var/www/html
From:http://www.111cn.net/sys/centos/68941.htm
CentOS 6.6 Configuration installation (Apache+php5+mysql) lamp server