国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
在CentOS 6上通過(guò)YUM安裝Nginx和PHP-FPM
在CentOS 6上通過(guò)YUM安裝Nginx和PHP-FPM
原文地址:http://www.lifelinux.com/how-to-install-nginx-and-php-fpm-on-centos-6-via-yum/


開始安裝Nginx和PHP-FPM之前,你必須卸載系統(tǒng)中以前安裝的Apache和PHP。用root登錄輸入下面的命令:

# yum remove httpd* php*

增加額外資源庫(kù)

默認(rèn)情況下,CentOS的官方資源是沒有php-fpm的, 但我們可以從Remi的RPM資源中獲得,它依賴于EPEL資源。我們可以這樣增加兩個(gè)資源庫(kù):

# yum install yum-priorities -y
  1. # rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
  2. # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

輸出樣例

Retrieving http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
  1. warning: /var/tmp/rpm-tmp.00kiDx: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
  2. Preparing...########################################### [100%]
  3. 1:epel-release ########################################### [100%]

安裝Nginx

輸入下列命令

# yum install nginx
輸出樣例

Dependencies Resolved
  1. ================================================================================
  2. Package Arch Version Repository Size
  3. ================================================================================
  4. Installing:
  5. nginx x86_64 0.8.54-1.el6 epel 358 k
  6. Installing for dependencies:
  7. GeoIP x86_64 1.4.8-1.el6 epel 620 k
  8. fontconfig x86_64 2.8.0-3.el6 base 186 k
  9. freetype x86_64 2.3.11-6.el6_1.8 updates 358 k
  10. gd x86_64 2.0.35-10.el6 base 142 k
  11. libX11 x86_64 1.3-2.el6 base 582 k
  12. libX11-common noarch 1.3-2.el6 base 188 k
  13. libXau x86_64 1.0.5-1.el6 base 22 k
  14. libXpm x86_64 3.5.8-2.el6 base 59 k
  15. libjpeg x86_64 6b-46.el6 base 134 k
  16. libpng x86_64 2:1.2.46-1.el6_1 base 180 k
  17. libxcb x86_64 1.5-1.el6 base 100 k
  18. libxslt x86_64 1.1.26-2.el6 base 450 k
  19. perl x86_64 4:5.10.1-119.el6_1.1 base 10 M
  20. perl-Module-Pluggable x86_64 1:3.90-119.el6_1.1 base 37 k
  21. perl-Pod-Escapes x86_64 1:1.04-119.el6_1.1 base 30 k
  22. perl-Pod-Simple x86_64 1:3.13-119.el6_1.1 base 209 k
  23. perl-libs x86_64 4:5.10.1-119.el6_1.1 base 575 k
  24. perl-version x86_64 3:0.77-119.el6_1.1 base 49 k
  25. Transaction Summary
  26. ================================================================================
  27. Install 19 Package(s)
  28. Upgrade 0 Package(s)
  29. Total download size: 14 M
  30. Installed size: 47 M
  31. Is this ok [y/N]: y

如果你想在系統(tǒng)啟動(dòng)時(shí)自動(dòng)運(yùn)行nginx,輸入下列命令:

# chkconfig --level 345 nginx on

第一次啟動(dòng)nginx,輸入下列命令:

# /etc/init.d/nginx start

輸出樣例

Starting nginx: [ OK ]

安裝PHP-FPM

輸入下列命令:

# yum --enablerepo=remi install php php-fpm

輸出樣例

Dependencies Resolved
  1. ====================================================================================
  2. Package Arch Version Repository Size
  3. ====================================================================================
  4. Installing:
  5. php x86_64 5.3.10-2.el6.remi remi 2.3 M
  6. php-fpm x86_64 5.3.10-2.el6.remi remi 1.1 M
  7. Installing for dependencies:
  8. apr x86_64 1.3.9-3.el6_1.2 base 123 k
  9. apr-util x86_64 1.3.9-3.el6_0.1 base 87 k
  10. apr-util-ldap x86_64 1.3.9-3.el6_0.1 base 15 k
  11. httpd x86_64 2.2.15-15.el6.centos.1 updates 813 k
  12. httpd-tools x86_64 2.2.15-15.el6.centos.1 updates 70 k
  13. libedit x86_64 2.11-4.20080712cvs.1.el6 base 74 k
  14. mailcap noarch 2.1.31-2.el6 base 27 k
  15. php-cli x86_64 5.3.10-2.el6.remi remi 2.2 M
  16. Transaction Summary
  17. ====================================================================================
  18. Install 10 Package(s)
  19. Upgrade 0 Package(s)
  20. Total download size: 6.8 M
  21. Installed size: 21 M
  22. Is this ok [y/N]: y

如果你想在系統(tǒng)啟動(dòng)時(shí)自動(dòng)運(yùn)行php-fpm,輸入下列命令:

# chkconfig --level 345 php-fpm on

PHP僅安裝了核心模塊,你很可能需要安裝其他的模塊,比如MySQL、 XML、 GD等等,你可以輸入下列命令:

# yum --enablerepo=remi install php-gd php-mysql php-mbstring php-xml php-mcrypt

第一次啟動(dòng)php-fpm,輸入下列命令:

# /etc/init.d/php-fpm restart

輸出樣例

Starting php-fpm: [ OK ]

配置PHP-FPM和Nginx,讓他們一起工作

nginx的配置文件在/etc/nginx/nginx.conf,輸入下列命令編輯這個(gè)文件:
# vi /etc/nginx/nginx.conf

像下面這樣編輯取消注釋:
  1. location / {
  2. root /usr/share/nginx/html;
  3. index index.html index.htm index.php;
  4. }
  5. ...
  6. location ~ \.php$ {
  7. root html;
  8. fastcgi_pass 127.0.0.1:9000;
  9. fastcgi_index index.php;
  10. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  11. include fastcgi_params;
  12. }
  13. ...

重啟Nginx會(huì)重新讀取配置文件,輸入
# /etc/init.d/nginx reload

現(xiàn)在在document root目錄下建立下列PHP文件

# vi /usr/share/nginx/html/info.php

文件內(nèi)容如下:

<?php
  1. phpinfo();
  2. ?>

訪問 http://YOUR-SERVER-IP


Nginx虛擬主機(jī)設(shè)置

設(shè)置例子

IP: 192.168.1.113
Domain: domain.local
Hosted at: /home/www/domain.local

輸入下列命令新建名叫“www”的用戶

# useradd www
創(chuàng)建必要的目錄

# mkdir -p /home/www/domain.local/public_html
  1. # mkdir -p /home/www/domain.local/log
  2. # chown -R www.www /home/www/
  3. # chmod 755 /home/www/

創(chuàng)建虛擬主機(jī)配置文件

# cd /etc/nginx/conf.d/
  1. # cp virtual.conf www.conf

輸入下面命令打開www.conf文件

# vi /etc/nginx/conf.d/www.conf

增加以下配置

server {
  1. server_name domain.local;
  2. root /home/www/domain.local/public_html;
  3. access_log /home/www/domain.local/log/domain.local-access.log;
  4. error_log /home/www/domain.local/log/domain.local-error.log;
  5. location / {
  6. index index.html index.htm index.php;
  7. }
  8. location ~ \.php$ {
  9. include /etc/nginx/fastcgi_params;
  10. fastcgi_pass 127.0.0.1:9000;
  11. fastcgi_index index.php;
  12. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  13. }
  14. }

你可以用下列方法檢查配置文件是否有語(yǔ)法錯(cuò)誤

# /etc/init.d/nginx configtest

輸出樣例

the configuration file /etc/nginx/nginx.conf syntax is ok
  1. configuration file /etc/nginx/nginx.conf test is successful

現(xiàn)在編輯/etc/php-fpm.d/www.conf文件,將運(yùn)行php-fpm進(jìn)程的用戶改為“www”,輸入

# vi /etc/php-fpm.d/www.conf
找到“group of processes”,編輯成下面的樣子:

; Unix user/group of processes
  1. ; Note: The user is mandatory. If the group is not set, the default user's group
  2. ; will be used.
  3. ; RPM: apache Choosed to be able to access some dir as httpd
  4. user = www
  5. ; RPM: Keep a group allowed to write in log dir.
  6. group = www

最后重啟nginx

# /etc/init.d/nginx restart
  1. # /etc/init.d/php-fpm restart
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
CentOS 7配置LNMP開發(fā)環(huán)境及配置文件管理
Centos 7.3搭建LNMP環(huán)境
yum安裝CentOS7+nginx+php7.3+mysql5.7
yum安裝nginx-mysql-php-fastcgi構(gòu)建LNMP服務(wù)器
就這22步讓你在30分鐘內(nèi)完成wordpress網(wǎng)站三位搭建
RHEL / CentOS 7 安裝 Nginx, MySQL, PHP (LEMP) | Linux 技術(shù)手札
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服