一、Nginx介紹
nginx(發音同engine x)是一款由俄羅斯程式設計師Igor Sysoev所開發輕量級的網頁伺服器、反向代理伺服器以及電子郵件(IMAP/POP3)代理伺服器。起初是供俄國大型的入口網站及搜尋引擎Rambler(俄語:Рамблер)使用。此軟體BSD-like協議下發行,可以在UNIX、GNU/Linux、BSD、Mac OS X、Solaris,以及Microsoft Windows等作業系統中執行。
二、系統配置 :
Centos 5.6
Nginx
PHP
MySQL
三、安裝步驟 :
添加安裝源:
[root@localhost ~]# vi /etc/yum.repos.d/alt.ru.repo
[CentALT]
name=CentALT Packages for Enterprise Linux 5 - $basearch
baseurl=http://centos.alt.ru/repository/centos/5/$basearch/
enabled=1
gpgcheck=0
1.1 啟用EPEL
i386
[root@localhost ~]# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
x86_64
[root@localhost ~]# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
1.2 輸入KEY
[root@localhost ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
安裝所需要的相關套件
2.1 update yum
[root@localhost ~]# yum -y update
2.2升級或安裝所需要的套件
[root@localhost ~]# LANG=C
[root@localhost ~]# yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
2.3 安裝PHP
[root@localhost ~]# yum -y install php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator php-mysql
2.4安裝MySQL
[root@localhost ~]# yum -y install mysql-server mysql-devel
安裝Nginx
[root@localhost ~]# yum -y install nginx
3.1 設定開機啟動
設定開機啟動有三種方式請選一種設定就可以了。
方法一:
[root@localhost ~]# echo "ulimit -SHn 65535" >> /etc/rc.d/rc.local
[root@localhost ~]# chkconfig --level 345 php-fpm on
[root@localhost ~]# chkconfig --level 345 nginx on
[root@localhost ~]# chkconfig --level 345 mysqld on
方法二:
[root@localhost ~]# vi /etc/rc.d/rc.local
#在最後面加入以下內容
ulimit -SHn 65535
/etc/init.d/php-fpm start
/usr/local/webserver/nginx/sbin/nginx
/data0/mysql/3306/mysql start
方法三:
[root@localhost ~]# echo "ulimit -SHn 65535" >> /etc/rc.d/rc.local
[root@localhost ~]# echo "/etc/init.d/php-fpm start " >> /etc/rc.d/rc.local
[root@localhost ~]# echo "/usr/local/webserver/nginx/sbin/nginx" >> /etc/rc.d/rc.local
[root@localhost ~]# echo "/data0/mysql/3306/mysql start" >> /etc/rc.d/rc.local
3.2 安裝spawn-fcgi來運行php-cgi
[root@localhost ~]# yum -y install spawn-fcgi
3.3下載spawn-fcgi 啟動腳本
3.4 查看進程是否正常
3.5 默認情況下PHP服務器監聽127.0.0.1:9000端口
Nginx yum安裝教學(Nginx+PHP+MySQL)(下)
全文同步於FAQ-BOOK
IT鐵人文章分享