CentOS 6.5 Yum installation configuration Lnmp server (nginx+php+mysql)

Source: Internet
Author: User
Tags configuration php fpm install php php script iptables

All of the following are reproduced in http://blog.csdn.net/lane_l/article/details/20235909

I followed this article tonight using the CentOS 6.7 64bit installation successfully, make a backup, and then turn around.

---------------------------------------------------------------

Reprint language:

Reproduced in: http://www.osyunwei.com/archives/2353.html

Original title: CentOS 6.2yum Installation Configuration Lnmp Server (nginx+php+mysql)

I CentOS6.5 the success of the test.

The following is the original text.

--------------------------------------------------------------------------------------------------------------- ---------------------

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:
#########################################################
# Firewall configuration written by System-config-firewall
# Manual Customization of this file are 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-mstate--state new-m tcp-p tcp--dport 80-j ACCEPT
-A input-mstate--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
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
Yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-b Cmath 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

# Pass the phpscripts 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 it to Date.timezone = PRC

Disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec

, Proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink

, Symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen

, Disk_free_space,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! #保存退出

(Reprint language: MAGIC_QUOTES_GPC My configuration is not exist, Open_basedir did not understand also skipped, these two did not affect my configuration success, hidden trouble ... Not found yet or not understood)

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

<?php
Phpinfo ();

?>

: 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

This tutorial currently (2012.2.14) installs the Nginx+php+mysql version as follows:

Nginx version:nginx/1.0.12

PHP 5.3.10 (CLI)

Server VERSION:5.5.20-CLL MySQL Community Server (GPL) by Atomicorp

CentOS 6.5 Yum installation configuration Lnmp server (nginx+php+mysql)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.