CentOS6.2/5.8下LNMP高性能的WEB服务器快速Yum搭建流程
本文将指导你如何在CentOS/Red Hat (RHEL) 6.2/5.8下使用Yum来搭建LEMP WEB服务器。国内
LNMP (Linux, Nginx, MySQL, PHP) 服务器目前在国内大的企业如百度腾讯使用非常普遍,但是因为LNMP不易安装配置,难为了许多运维人员。在本安装中,我尽量使用yum安装而避免编译安装,有将有效减少安装过程的时间及复杂程序。
LEMP(或LNMP)高性能的WEB服务器在CentOS6.2/5.8下的Yum搭建流程
STEP1.切换到root用户
su - ## OR ## sudo -i
STEP2.安装必要的软件源
1. 安装Remi源
2.配置Nginx 源
创建/etc/yum.repos.d/nginx.repo文件并写入以下内容
CentOS
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
RedHat(RHEL)
[nginx] name=nginx repo baseurl=http://nginx.org/packages/rhel/$releasever/$basearch/ gpgcheck=0 enabled=1
STEP3.安装Nginx
yum --enablerepo=remi,remi-test install nginx
STEP4.安装PHP5.4.4&PHP-FPM
yum --enablerepo=remi,remi-test install php php-fpm php-common
STEP5.安装PHP5.4.4模块扩展(一些扩展可能无用,请自行去除)
yum --enablerepo=remi,remi-test install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xmlSTEP6.停止并禁用httpd服务,启动Nginx HTTP服务及PHP-FPM
1. 停止httpd
/etc/init.d/httpd stop ## OR ## service httpd stop chkconfig httpd off2. 启动Nginx
/etc/init.d/nginx start ## OR ## service nginx start
3. 启动PHP_FPM
/etc/init.d/php-fpm start ## OR ## service php-fpm start
4. 配置nginx使用PHP-FPM,修改/etc/nginx/conf.d/default.conf
(1) 先为/etc/nginx/conf.d/default.conf作一个备份
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf_bak
(2) 在default.conf 文件中,找到以下内容。
location / { root /usr/share/nginx/html; index index.html index.htm; }
修改为:
location / { root /usr/share/nginx/html; index index.html index.htm index.php; }nginx默认的wwwroot文件夹为/usr/share/nginx/html,这里你可以修改为自己指定的目录
(3) 去除以下内容前的#号,并修改fastcgi_param所在行
#location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME [将此处修改为wwwroot路径]$fastcgi_script_name; # include fastcgi_params; #}
修改结果
location ~ \.php$ { root 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; }
相关推荐
FCLAMP 2020-05-20
yishouwangnian 2020-06-21
昭君出塞 2020-06-04
flycappuccino 2020-09-27
xiemanR 2020-09-21
数据人 2020-10-26
张立军的架构之路 2020-09-28
xiaohai 2020-09-16
87901735 2020-08-19
zhangll00 2020-07-29
ningningmingming 2020-07-26
young依然 2020-07-19
VFCSDN 2020-07-05
87447007 2020-07-04
kuailexiaochuan 2020-07-04