YUM安装LNMP环境

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了YUM安装LNMP环境相关的知识,希望对你有一定的参考价值。

环境:Centos 6.6

[[email protected] ~]# /etc/init.d/iptables status
iptables: Firewall is not running.
[[email protected] ~]# getenforce
Disabled
[[email protected] ~]#

 

安装nginx

[[email protected] ~]# yum -y remove httpd
[[email protected] ~]# yum -y install nginx
[[email protected] ~]# chkconfig nginx on


安装mysql

[[email protected] ~]# yum -y install mysql mysql-server mysql-devel
[[email protected] ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
[[email protected] ~]# chkconfig mysqld on
[[email protected] ~]# /etc/init.d/mysqld start
[[email protected] ~]# mysqladmin -uroot password "redhat"
[[email protected] ~]# mysql_secure_installation


安装php及其依赖包:

[[email protected] ~]# yum -y install php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm php-cli php-pdo php-tidy php-pecl-memcache php-eaccelerator
[[email protected] ~]# chkconfig php-fpm on


配置Nginx:

[[email protected] ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
[[email protected] ~]# cd /etc/nginx/conf.d/
[[email protected] conf.d]# cp default.conf default.conf.bak
[[email protected] conf.d]# grep -v ‘#‘ /etc/nginx/nginx.conf|grep -v ^$ |head -2
user nginx nginx;
worker_processes  5;
[[email protected] ~]#
[[email protected] conf.d]# grep -v ‘#‘ default.conf |grep -v ^$
server {
    listen       80;
    server_name  192.168.31.160;
    include /etc/nginx/default.d/*.conf;
    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }
    location ~ ^(.+.php)(.*)$ {
        root /var/www/html;
        fastcgi_split_path_info ^(.+.php)(.*)$;
        include fastcgi.conf;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
 fastcgi_param  PATH_INFO          $fastcgi_path_info;
    }
    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
[[email protected] conf.d]#


配置PHP:

[[email protected] ~]# cd /etc/php-fpm.d/
[[email protected] php-fpm.d]# grep nginx www.conf
user = nginx
group = nginx
[[email protected] php-fpm.d]#
[[email protected] ~]# cd /var/www/html/
[[email protected] html]# cat info.php
<?php
phpinfo();
?>
[[email protected] www]# chown nginx:nginx html/ -R
[[email protected] ~]# /etc/init.d/php-fpm start
Starting php-fpm:                                          [  OK  ]
[[email protected] ~]#
[[email protected] ~]# /etc/init.d/nginx start
Starting nginx:                                            [  OK  ]
[[email protected] ~]#


技术分享

技术分享


本文出自 “鹏城-酱油瓶” 博客,谢绝转载!

以上是关于YUM安装LNMP环境的主要内容,如果未能解决你的问题,请参考以下文章

linux环境搭建lnmp环境

阿里云centos6(32bit)yum安装lnmp环境

部署LNMP环境——Yum安装(113资讯网)

使用yum安装LNMP步骤

用LNMP环境搭建Wordpress博客(yum安装)

本地虚拟机LNMP环境安装