Linux Yum installation Lnmp (LINUX+PHP+MYSQL)

Source: Internet
Author: User
Tags fpm install php openssl

Yum Build LNMP Environment (CENTOS6)

1. Turn off the firewall
[Email protected] ~]# chkconfig iptables off

2. Turn off SELinux
Vi/etc/sysconfig/selinux
Modify selinux=enforcing to disabled and then restart to take effect

3. Configure CentOS 6.0 third-party yum Source (no Nginx package in CentOS default standard source)
[email protected] ~]# Yum install wget
Download wget Tools
[Email protected] ~]# wget http://www.atomicorp.com/installers/atomic
Download Atomic Yum Source
[Email protected] ~]# sh./atomic
Enter Yes when prompted for installation
[email protected] ~]# Yum check-update
Update Yum Packages

4. Install the package and library files
[[email protected] ~]# 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 the installed Apache, MySQL, PHP
[email protected] ~]# Yum Remove httpd
[[email protected] ~]# Yum remove MySQL
[[email protected] ~]# Yum remove php

6. Installing Nginx
[[email protected] ~]# Yum install Nginx
[[Email protected] ~]# service Nginx start
[Email protected] ~]# chkconfig--levels 235 nginx on
Set 2, 3, 5-stage boot

7. Install MySQL
[email protected] ~]# yum install MySQL mysql-server mysql-devel
[[Email protected] ~]# service mysqld start
[Email protected] ~]# chkconfig--levels 235 mysqld on
[[email protected] ~]# mysqladmin-u root password "123456"
To set a password for the root user
[Email protected] ~]# service mysqld restart
Restart MySQL

8. Install PHP
[email protected] ~]# 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
Php-tidy Php-common Php-devel php-fpm
Install PHP and the required components to enable PHP to support MySQL, fastcgi mode
[[Email protected] ~]# service PHP-FPM start
[Email protected] ~]# chkconfig--levels 235 php-fpm on

9. Configure Nginx Support PHP
[Email protected] ~]# Mv/etc/nginx/nginx.conf/etc/nginx/nginx.confbak
Change the configuration file to a backup file
[Email Protected]tos ~]# cp/etc/nginx/nginx.conf.default/etc/nginx/nginx.conf
Since the original profile is going to be written by itself, you can use the default configuration file as the profile
Modify Nginx configuration file, add fastcgi support
[Email protected] ~]# vi/etc/nginx/nginx.conf
Index index.php index.html index.htm;
Join 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 above code comments and modify the default path to Nginx

10. Configure PHP
Edit the file php.ini, add Cgi.fix_pathinfo = 1 at the end of the file
[Email protected] ~]# Vi/etc/php.ini

11. Restart Nginx PHP-FPM
[[Email protected] ~]# service Nginx restart
[Email protected] ~]# service PHP-FPM restart

12. Create a info.php file
[Email protected] ~]# vi/usr/share/nginx/html/info.php
<?php
Phpinfo ();
?>

13. Because my network segment is 172 of all browsers in the 172.16.10.12 to see if PHP is configured successfully

###########################

14. Personal Summary

Nginx Configuration file Directory/etc/nginx/nginx.conf

/etc/nginx/conf.d/default.conf

PHP.ini Directory

[Email protected] nginx]# Whereis php.ini
PHP:/usr/bin/php/etc/php.ini/etc/php.d/usr/lib64/php/usr/include/php/usr/share/php/usr/share/man/man1/php.1.gz

Verifying MySQL

[Email protected] nginx]# mysql-uroot-p
Enter password: [Enter]

mysql> show databases; Come here to show that MySQL has been installed successfully

#################

Configuration in the nginx.conf

HTTP {
Include Mime.types;
Default_type Application/octet-stream;

Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" "$http _x_forwarded_for";

Access_log/var/www/log/nginx/access.log main;

Sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
Keepalive_timeout 65;

#gzip on;
# Load config files from the/etc/nginx/conf.d directory
include/etc/nginx/conf.d/*.conf;
server {
Listen 80;
server_name localhost;

#charset Koi8-r;

#access_log Logs/host.access.log Main;

Location/{
root/var/www/;
Index index.php index.html index.htm;
}

Error_page 404/404.html;
Location =/404.html {
root/usr/share/nginx/html;
}

# REDIRECT Server error pages to the static page/50x.html
Error_page 502 503 504/50x.html;
Location =/50x.html {
root/usr/share/nginx/html;
}
}
}

Create a new default.conf configuration file in the CONF.D directory

Vim default.conf

server {
Listen 80;
server_name _;
root/var/www/;

Location/{
Index index.php index.html index.htm;
if (-e $request _filename) {
Break
}
if (!-e $request _filename) {
Rewrite ^/(. *) $/index.php/$1 last;
Break
}
}

Location ~. +\.php ($|/) {
root/var/www/;
Fastcgi_index index.php;
Fastcgi_split_path_info ^ (. +\.php) (. *) $;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_param path_info $fastcgi _path_info;
Fastcgi_param path_translated $document _root$fastcgi_path_info;
Fastcgi_pass 127.0.0.1:9000;
Include Fastcgi_params;
}
}

Linux Yum installation Lnmp (LINUX+PHP+MYSQL)

Related Article

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.