Prepare the article:
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 (allow 80 ports via firewall)
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT (Allow 3306 ports via firewall)
Special Note: Many netizens add these two rules to the last line of the firewall configuration, causing the firewall to fail to start, the correct one should be added to the default 22 port under this rule
After adding the firewall rules as follows:
#########################################################
123456789101112131415 |
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-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
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
|
#########################################################
/etc/init.d/iptables Restart #最后重启防火墙使配置生效
2. Turn off SELinux
Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
: Wq Save, close
Shutdown-r now #重启系统
3. Configure CentOS 6.2 Third-party yum Source (no Nginx package in CentOS default standard source)
Yum Install wget #安装下载工具wget
1 |
wget http: //www .atomicorp.com /installers/atomic |
#下载atomic Yum Source
Sh./atomic #安装
Yum Check-update #更新yum软件包
################################################################
Installation article:
First, install Nginx
Yum install Nginx #安装nginx, follow the prompts, enter the Y installation can be installed successfully
Service Nginx Start #启动
Chkconfig Nginx on #设为开机启动
/etc/init.d/nginx Restart #重启
rm-rf/usr/share/nginx/html/* #删除ngin默认测试页
Second, install MySQL
1. Install MySQL
Yum install MySQL mysql-server #询问是否要安装, enter y for automatic installation until 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 under the default, you can directly overwrite it)
Shutdown-r now #重启系统
2. Set the password for the root account
Mysql_secure_installation
Enter, follow the prompts for Y
Enter Password 2 times, enter
Enter Y as prompted
Last appearance: Thanks for using mysql!
MySQL password setup is complete, restart MySQL:
/etc/init.d/mysqld Stop #停止
/etc/init.d/mysqld Start #启动
Service mysqld Restart #重启
Third, install PHP
1. Install PHP
Yum Install PHP #根据提示输入Y直到安装完成
2, install PHP components, so that PHP support MySQL, PHP support fastcgi mode
1 |
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash  LIBMCRYPT LIBMCRYPT-DEVEL PHP-FPM |
#根据提示输入Y回车
/etc/init.d/mysqld Restart #重启MySql
/etc/init.d/nginx Restart #重启nginx
/ETC/RC.D/INIT.D/PHP-FPM Start #启动php-fpm
Chkconfig PHP-FPM on #设置开机启动
################################################################
Configuration Chapter
First, the configuration Nginx support PHP
Cp/etc/nginx/nginx.conf/etc/nginx/nginx.confbak #备份原有配置文件
Vi/etc/nginx/nginx.conf #编辑
User Nginx Nginx; #修改nginx运行账号为: Nginx User of Nginx Group
: wq! #保存退出
Cp/etc/nginx/conf.d/default.conf/etc/nginx/conf.d/default.confbak #备份原有配置文件
Vi/etc/nginx/conf.d/default.conf #编辑
Index index.php index.html index.htm; #增加index. php
123456789 |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
|
#取消FastCGI the comment for the server section location, and note the parameters of the Fastcgi_param row, change to $document_root$fastcgi_script_name, or use the absolute path
Second, configure PHP
Vi/etc/php.ini #编辑
Date.timezone = PRC #在946行 Remove the preceding semicolon and change to Date.timezone = PRC
1 |
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
Open_basedir =.:/ tmp/#在380行, set 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, you can log off this line, or directly write the program directory path/var/www/html/ www.osyunwei.com/:/tmp/
: wq! #保存退出
Third, configuration php-fpm
Cp/etc/php-fpm.d/www.conf/etc/php-fpm.d/www.confbak #备份原有配置文件
Vi/etc/php-fpm.d/www.conf #编辑
user = Nginx #修改用户为nginx
Group = Nginx #修改组为nginx
/etc/init.d/mysqld Restart #重启MySql
/etc/init.d/nginx Restart #重启nginx
/ETC/RC.D/INIT.D/PHP-FPM Restart #重启php-fpm
################################################################
Test article
cd/usr/share/nginx/html/#进入nginx默认网站根目录
VI index.php #新建index. php file
: wq! #保存
Chown nginx.nginx/usr/share/nginx/html/-R #设置目录所有者
chmod 700/usr/share/nginx/html/-R #设置目录权限
In the client browser enter the server IP address, you can see the relevant configuration information!
################################################################
Note
Nginx Default Site Directory is:/usr/share/nginx/html/
Permission settings: Chown nginx.nginx/usr/share/nginx/html/-R
MySQL database directory is:/var/lib/mysql
Permission settings: Chown mysql.mysql-r/var/lib/mysql
Reference Document: Http://www.osyunwei.com/archives/2353.html
Https://zhidao.baidu.com/question/362471324498583292.html
CentOS 6 Yum Installation LMP