Set up LNMP and centos6.5lnmp in CentOS6.5
1: view the environment:
?
12 |
[root@10-4-14-168 html]# cat /etc/redhat-release CentOS release 6.5 (Final) |
2. Disable the firewall.
?
1 |
[root@10-4-14-168 html]# chkconfig iptables off |
3: configure the CentOS 6.0 third-party yum source (the nginx package is not included in the standard source of CentOS by default)
?
1 |
#wget http://www.atomicorp.com/installers/atomic |
?
?
4. Install the development kit and library files
?
1234 |
#yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel |
5. Uninstall installed apache, mysql, and php
?
123 |
# yum remove httpd # yum remove mysql # yum remove php |
6. Install nginx
?
1234 |
# yum install nginx # service nginx start # chkconfig --levels 235 nginx on // Set 2, 3, and 5 levels for startup |
7. Install mysql
?
123 |
# yum install mysql mysql-server mysql-devel # service mysqld start # chkconfig --levels 235 mysqld on |
?
12345678 |
Log on to MySQL to delete empty users and change the root password. mysql> select user ,host, password from mysql. user ; mysql> drop user '' @localhost; mysql> update mysql. user set password = PASSWORD ( '*********' ) where user = 'root' ; mysql>flush privileges ; |
8: install php
?
12 |
# yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap |
// Install php and required components so that PHP supports MySQL and FastCGI Modes
?
1 |
#yum install php-tidy php-common php-devel php-fpm php-mysql |
?
12 |
# service php-fpm start # chkconfig --levels 235 php-fpm on |
9: Configure nginx to support php
?
12345678910111213141516171819 |
# mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak / / Change the configuration file to a backup file. # cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf / / Because the original configuration file needs to be written by yourself, you can use the default configuration file as the configuration file. / / Modify the nginx configuration file and add fastcgi support # vi /etc/nginx/nginx.conf index index.php index.html index.htm; / / Add index. php location ~ \.php$ { root / usr / share / nginx / html; fastcgi_pass 127.0 . 0.1 : 9000 ; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME / usr / share / nginx / html$fastcgi_script_name; include fastcgi_params; } / / Remove the preceding code comments and change them to the nginx default path. |
?
10: Configure php
?
12 |
// Edit the php. ini file and add cgi. fix_pathinfo = 1 at the end of the file. [root@CentOS ~]# vi /etc/php.ini |
11: restart nginx php-fpm
?
12 |
# service nginx restart # service php-fpm restart |
12: Create the info. php file.
?
1234 |
# vi /usr/share/nginx/html/info.php <?php phpinfo(); ?> |
13: test whether nginx parses php
?
12 |
Enter 192.168.1.105/info. php In the local browser. The php interface environment is successfully set up. |