Reposter’s words:
Reprinted in:http://www.osyunwei.com/archives/2353.html
Original title: CentOS 6.2yum installation and configuration lnmp server (Nginx+PHP+MySQL)
I am CentOS6.5 was tested successfully.
The following is the original text.
---------------------------------- -------------------------------------------------- --------------------------------------------------
Preparation:
1, configure the firewall, open the 80port, 3306port
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT (allow port 80 to pass through the firewall)
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT (allow port 3306 to pass through the firewall)
Special reminder: 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 to add them below the default 22port rule
After adding the firewall rules It looks like this:
############################################ ############
# 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 -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 #Finally restart the firewall to make the configuration take effect
2, close SELINUX
vi / etc/selinux/config
#SELINUX=enforcing #Comment out
#SELINUXTYPE=targeted #Comment out
SELINUX=disabled #Add
:wq Save, close
shutdown -r now #Restart the system
3, configuration CentOS 6.2Third partyyumsource(CentOSThe default standard source does not have nginxpackage)
yum install wget #Install download tool wget
wget http:// /www.atomicorp.com/installers/atomic #Download atomic yum source
sh ./atomic #Install
yum check-update #Update yum package
############### ################################################ ############
Installation:
1. Installationnginx
yum install nginx #Install nginx, follow the prompts, enter Y to install to successfully install
service nginx start #Start
chkconfig nginx on #Set to start at boot
/etc/init.d/nginx restart #Restart
rm -rf /usr/share/nginx/html/* #Delete ngin default test page
2. Install MySQL1, install mysql
yum install mysql mysql-server #Ask if you want to install, enter Y to install automatically until the installation is completed
/etc/init.d/ mysqld start #Start MySQL
chkconfig mysqld on #Set to start at boot
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #Copy the configuration file (note: if it is under the /etc directory There is a my.cnf by default, just overwrite it directly)
shutdown -r now #Restart the system
2, set a password for the root account
mysql_secure_installation
Press Enter and enter Y as prompted
Enter the password twice and press Enter
Enter Y all the way as prompted
Finally: Thanks for using MySQL!
MySql password setting is completed, restart MySQL:
/etc/init.d/mysqld stop #stop
/etc /init.d/mysqld start #Start
service mysqld restart #Restart
3. Install PHP
1, install PHP
yum install php #Enter Y according to the prompts until the installation is complete
2, install the PHP component, use PHP Supports MySQL, PHPSupports FastCGImodeyum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-x mlphp- xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm #Enter Y according to the prompts and press Enter
/etc/init.d/mysqld restart #Restart MySql
/etc/init.d/nginx restart #Restart nginx
/etc/rc.d/init.d/php-fpm start #Startphp-fpm
chkconfig php-fpm on #Set boot up##### ################################################ #####################Configuration Chapter
1. ConfigurationnginxSupportphpcp /etc/nginx/ nginx.conf /etc/nginx/nginx.confbak #Back up the original configuration file
vi /etc/nginx/nginx.conf #Edit
user nginx nginx; #Modify the nginx running account to: nginx user of the nginx group
vi /etc/nginx/conf.d/default. conf #Edit
index index.php index.html index.htm; #Add 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;
}
# Uncomment the location of the FastCGI server part, and pay attention to the parameters of the fastcgi_param line, change it to $document_root$fastcgi_script_name, or use an absolute path
2. Configurationphp
vi /etc/php.ini #Editdate.timezone= PRC #Remove the previous semicolon on line 946 and change it to date.timezone = PRCdisable_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,pos ix_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_setui d,posix_strerror,posix_times,posix_ttyname,posix_uname#List PHP on line 386 Disabled functions, if some programs need to use this function, can be deleted and undisabled.
expose_php = Off #In line 432, the display of php version information is prohibited.
magic_quotes_gpc = On The directory where the script file is located) and the /tmp/ directory can prevent PHP Trojans from crossing sites. If there are problems with the installation program after changing it, you can log out of this line, or directly write the program directory path /var/www/html/www.osyunwei .com/:/tmp/
Save and exit
(Reposter’s words: magic_quotes_gpc does not exist in my configuration, open_basedir did not understand it and skipped these two items It did not affect the success of my configuration. The hidden danger... I have not found or understood it yet)3. Configuration
php-fpmcp /etc/php-fpm.d/www.conf /etc/ php-fpm.d/www.confbak #Back up the original configuration filevi /etc/php-fpm.d/www.conf #Edit /etc/init.d/mysqld restart #Restart MySql ?> :wq! #Save chown nginx.nginx /usr/share/nginx/ html/ -R #Set directory owner chmod 700 /usr/share/nginx/html/ -R #Set directory permissions Enter the server IP address in the client browser and you can see the relevant configuration information! Remarks nginxThe default site directory is: /usr/share /nginx/html/ Permission settings: chown nginx.nginx/usr/share/nginx/html/ -R MySQLThe database directory is: /var/lib/mysql Permission settings: chown mysql.mysql -R /var/lib/mysql This tutorial currently (2012.2.14) installs Nginx+PHP+MySQLThe version is 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
The above introduces the CentOS 6.5 yum installation and configuration of the lnmp server (Nginx+PHP+MySQL), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.
user = nginx
#Modify the user to nginxgroup = nginx
#Modify Group for nginx
/etc/init.d/nginx restart #Restart nginx
/etc/rc.d/init.d/php-fpm restart #Restartphp-fpm
# ################################################ ########################
Test articlecd /usr/share/nginx/html/ #Enter nginx default website root directory
vi index.php #New index.php file
phpinfo();
############################################## ##########################