LNMP环境的搭建
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這里定義一個新的目錄)
./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?
如果出現錯誤: checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
則安裝這個 yum -y install curl-devel即可解決
make && make install?
拷貝啟動腳本:
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?
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.2
./configure? ?--prefix=/usr/local/nginx? ?--with-pcre?
如果這一步報錯提示 ./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搭建成功 |
轉載于:https://blog.51cto.com/825536458/1702441
總結
- 上一篇: 没有Hyper-V服务,WP Emula
- 下一篇: HDU 3037 Saving Bean