1. MySQL安裝(同LAMP 裏面的安裝方法)
2. php安裝
wget http://cn2.php.net/distributions/php-5.4.37.tar.bz2
tar jxf php-5.4.37.tar.bz2
useradd -s /sbin/nologin php-fpm
cd php-5.4.37(若是你不想這個覆蓋你的 lamp的php 你能夠在 —prefix這裏定義一個新的目錄)php
./configure --prefix=/usr/local/php2 --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-curl html
若是出現錯誤: checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -mysql
easy.h should be in /include/curl/nginx
則安裝這個 yum -y install curl-devel便可解決sql
make && make install vim
拷貝啓動腳本:
cp /usr/local/src/php-5.4.37/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
mv /usr/local/php2/etc/php-fpm.conf.default /usr/local/php2/etc/php-fpm.conf
chmod 755 /etc/init.d/php-fpm
chkconfig --add php-fpm
service php-fpm start
chkconfig php-fpm on api
3 nginx的安裝
瀏覽器
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2curl
./configure --prefix=/usr/local/nginx --with-pcre ide
若是這一步報錯提示 ./configure: error: the HTTP rewrite module requires the PCRE library.
則能夠安裝 yum -y install pcre-devel 解決問題
make
make install
啓動nginx:
/usr/local/nginx/sbin/nginx
加上-t 能夠檢查配置文件是否正確
4 設置解析php文件
. 配置解析php
vim /usr/local/nginx/conf/nginx.conf //把下面的配置,前面的#刪除, 並更改fastcgi_param SCRIPT_FILENAME 那一行
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
從新加載 /usr/local/nginx/sbin/nginx -s reload 檢查配置文件/usr/local/nginx/sbin/nginx -t 最後能夠成功解析php 若是想關閉nginx的服務能夠 killall -9 nginx 注意:若是這裏拒接訪問,多是php.ini這個配置文件裏設置了open_basdir 測試可否正常解析php文件,寫一個php文件 vim /usr/local/nginx/html/1.php 而後,在瀏覽器中輸入http://ip/1.php 看可否訪問,若是正常,則lnmp搭建成功 |