This article mainly introduces, the simple construction LNMP environment, own environment, own decision
Preparation requirements: The new LIUNX environment, this article uses the centerOS6.0
Nonsense not much to say, look directly at the steps:
1. Open nginx80 port and mysql3306 port
Vim/etc/sysconfig/iptables
You can see that two ports have been opened.
So imitate here continue to add port
Add the following code:
-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 save exit, restart Firewall
/etc/init.d/iptables restart
2. Turn off SELinux
Vim/etc/selinux/config
Comment out all the code inside, add the following code:
Selinux=disabled
: Wq save exit, reboot system
Shutdown-r now
SELinux is a Linux security enhancement tool that is a security subsystem that can control programs to access only specific files
3. Install a third-party yum Source
Install the Download tool
Yum Install wget
wget www.atomicorp.com/installers/atomic
The installation process takes a certain amount of time, please wait patiently, the installation completes continue to go down
Sh./atomic
Then execute the following code:
echo $?
such as output 0, indicating success
Update Yum Source
Yum Check-update
4. Installing Nginx
Remove the package that comes with your system
Yum Remove httpd* php* mysql*
Installing Nginx
Yum install-y Nginx
Installation takes a certain amount of time, please wait patiently
After the installation is complete, set the Nginx boot to start automatically
Chkconfig Nginx on
Start Nginx Service
Service Nginx Start
5. Install PHP
Configure the installation package source, download the PHP package source according to your own CentOS version
Centos5. X
RPM-UVH http://mirror.webtatic.com/yum/el5/latest.rpm
Centos6. X
RPM-UVH http://mirror.webtatic.com/yum/el6/latest.rpm
Centos7. X
RPM-UVH https://mirror.webtatic.com/yum/el7/epel-release.rpm
RPM-UVH https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
If you want to remove the above installation package, reinstall
Rpm-qa | grep webstatic
RPM-E [the package found above]
Perform the installation (installed here is the php5.6 version, if you want to install php5.5 or 5.4 version, directly the following 56w to 55w or 54w)
Yum-y Install php56w.x86_64
Yum-y--enablerepo=webtatic Install Php56w-devel
Installing the PHP expansion pack
Yum-y Install php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 Php56w-pdo.x86_64 php56w-opcache.x86_64
Install PHP FPM
Yum-y Install PHP56W-FPM
Set PHP-FPM boot up
Chkconfig PHP-FPM on
Start PHP-FPM
/ETC/INIT.D/PHP-FPM start
6. Install MySQL
Yum install-y MySQL Mysql-server
Installation takes a certain amount of time, please wait patiently
After the installation is complete, start MySQL
/etc/init.d/mysqld start
Set to boot
Chkconfig mysqld on
Copy configuration file (/etc directory default MY.CNF, directly overwrite on the line)
Cp/usr/sgare/mysql/my-medium.cnf/etc/my.cnf
Set Root password
Mysql_secure_installation
Restart MySQL
/etc/init.d/mysqld restart
MySQL Boot
/etc/init.d/mysqld start
MySQL Stop
/etc/init.d/mysqld stop
7. Configure Nginx
Cd/etc/nginx/conf.d
MV Default.conf Default.conf.bak
Vim default.conf
Add the following content:
server{
Listen 80;
server_name _;
Index index.php index.html index.htm;
root/home/html/www;
Location ~. *\. (PHP|PHP5)? $
{
#fastcgi_pass Unix:/tmp/php-cgi.sock;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Include fastcgi.conf;
}
Location/{
Try_files $uri $uri//index.php? $query _string;
}
}
Description: Place the Web root directory in/home/html/www, so go to/home to create a new directory
Mkdir/home/html/www
Configure PHP-FPM
Vi/etc/php-fpm.d/www.conf
Modify the user name Nginx
user = Nginx
Fix to Nginx
Group = Nginx
8. Start testing
vi/home/html/www/index.php
Add the following code:
<?php
Echo Phpinfo ();
?>
: Wq Save Exit
Set permissions
Chown Nginx.nginx/home/html/www-r
Re-start Nginx
Service Nginx Restart
Restart PHP-FPM
Service PHP-FPM Restart
Then enter the server IP address in the client browser address bar, such as 192.168.179.10/index.php
Configuration information appears stating that the build was successful
9. Comments:
This procedure is just installed under the centos6.0 system, so the process down, and there is nothing wrong, the installation of PHP version for the 5.6,php extension is also installed a simple must use, such as the GD Library, PDO Library, MySQL extension.
If you have some errors in this process, such as, welcome message, we discuss together!!
Reprint Please specify: HTTP://WWW.CNBLOGS.COM/TTSQX
Construction of linux+nginx+mysql+php Environment