Centos服务器yum安装lnmp
本帖最后由 米拿现’ 于 2015-10-10 17:42 编辑
[root@localhost ~]# wget http://www.atomicorp.com/installers/atomic (下载yum 源脚本)
[root@localhost ~]# sh ./atomic (执行脚本)
[root@localhost ~]# yum check-update (更新 yum )
接下来,就开始装了哦…
[root@localhost ~]# yum install nginx -y
[root@localhost ~]# yum install mysql-server -y
[root@localhost ~]# yum install php -y
[root@localhost ~]# yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm (安装php 组件)
好了.以上就是 lnmp 环境的完整 安装了..
接下来 我们把装好的服务都开启..
[root@localhost ~]# service nginx start (启动nginx)
[root@localhost ~]# chkconfig nginx on (开机自动启动)
[root@localhost ~]#servie mysqld start (启动mysql)
[root@localhost ~]#chkconfig mysqld on(开机自动启动)
[root@localhost ~]# service php-fpm start (启动php组件 )
[root@localhost ~]# chkconfig php-fpm on
下面接下来就是配置 nginx 与php整合
[root@localhost ~]# vim /etc/nginx/nginx.conf
user nginx nginx; (添加nginx 属组与用户)
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
"/etc/nginx/nginx.conf" 69L, 1940C
[root@localhost ~]# vim /etc/nginx/conf.d/default.conf
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php ; (在此行加入index.php)
}
########################################################
# pass the PHP scripts 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 /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
########################################################
把#里面的代码 稍微改动一下就OK 了..
#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径 改成这样
# pass the PHP scripts 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;
}
接下来 配置 php
vim /etc/php.ini
在957 行 需要改下
把前面的注释去掉,改成 date.timezone =PRC
在431 把php 版本信息关闭掉..
改成
expose_php = Off
好了 php 我只简洁了介绍..具体还得靠大家回帖 发些更好的方法
再就是配置 php -fpm
更改 属组与用户
[root@localhost ~]# vim /etc/php-fpm.d/www.conf
user = nginx 默认是(apache)
; RPM: Keep a group allowed to write in log dir.
group = nginx
:wq 保存退出
重启 nginx ,mysql ,php-fpm 这3个 服务
[root@localhost ~]# service nginx restart
Stopping nginx: [ OK ]
Starting nginx: [ OK ]
[root@localhost ~]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@localhost ~]# service php-fpm restart
Stopping php-fpm: [ OK ]
Starting php-fpm: [ OK ]
[root@localhost ~]#
下面就开始 测试了..
进入网页的默认根目录
[root@localhost ~]# cd /usr/share/nginx/html/
[root@localhost html]# ls
404.html atomic_bg.png gradient_bg.png nginx-logo.png
50x.html atomicorp_logo.png index.html
[root@localhost html]# rm -rf * (删除默认测试)
[root@localhost html]# ls
[root@localhost html]# vim index.php (内容为)
<?php
phpinfo();
?>
(保存退出) 下面给权限和属主
[root@localhost html]# chown -R nginx:nginx /usr/share/nginx/html/
[root@localhost html]# chmod 700 /usr/share/nginx/html/
[root@localhost html]#
php 环境成功的测试页面
atomic.rar (3.54 KB, 下载次数: 0)