安装lnmp常见错误
http://blog.csdn.net/dodott/article/details/49664379
php7 --with-curl
yum install curl-devel
yum -y install libjpeg-devel
yum -y install libpng-devel
参考http://blog.163.com/lgh_2002/blog/static/44017526201292002213446/
centos pcre
yum -y install pcre-devel openssl openssl-devel
1、安装php
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysqlserver --with-mysqli=/usr/local/mysqlserver/bin/mysql_config --with-iconv-dir=/usr/local/libiconv --with-curl --with-curlwrappers --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-zlib --with-freetype-dir --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-sockets --enable-soap --with-openssl --enable-bcmath --enable-fastcgi --enable-fpm --enable-json --enable-xml --with-fpm-user=nobody --with-fpm-group=nobody
make & make install
sudo apt-get install openssl
sudo apt-get install libssl-dev
在configure后,又出现错误提示:error: xml2-config not found. Please check your libxml2 installation.
sudo apt-get install libxml2
sudo apt-get install libxml2-dev
提示找不到lib-curl
apt-get install libcurl3
apt-get install libcurl3-dev
2、安装nginx
如果提示安装pcre,那么ubuntu
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
如果提示安装gd库,那么
sudo apt-get install libgd2-xpm libgd2-xpm-dev
支持geo_ip
aptitude install libgeoip-dev
root@test:/home/test/nginx-0.8.32# ./configure --add-module=/home/test/ngx_cache_purge-1.0/ --add-module=/home/test/gnosek-nginx-upstream-fair-a18b409 --add-module=/home/test/nginx-static-etags-master --add-module=/home/test/nginx-dynamic-etags-master --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_random_index_module --with-http_realip_module --with-http_sub_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_addition_module --add-module=/home/test/nginx-accesskey-2.0.3 --with-http_geoip_module
root@test:/home/test/nginx-0.8.32# make && make install
如报错,更换版本看看,最好用上面的
root@victor:/home/victor/nginx-1.0.15# ./configure --add-module=/home/victor/ngx_cache_purge-1.3 --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_random_index_module --with-http_realip_module --with-http_sub_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_addition_module
重启 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
均匀过渡 /usr/local/nginx/sbin/nginx -s reload
3、运行php-fpm
配置 vim /usr/local/php5/etc/php-fpm.conf
user=nobody
group=nobody
pid = run/php-fpm.pid
ps aux|grep php-fpm
netstat -ntlp|grep 9000
killall php5-fpm
/etc/init.d/php-fpm restart
mkdir /var/log/php-fpm chown -R www-data:www-data /var/log/php-fpm
准备PHP的配置文件:
cp -f php.ini-production /opt/php5/etc/php.ini
chmod 644 /opt/php5/etc/php.ini
cp /opt/php5/etc/php-fpm.conf.default /opt/php5/etc/php-fpm.conf
注意: PHP5的配置文件在/opt/php5/etc/php.ini, php-fpm的配置文件在/opt/php5/etc/php-fpm.conf.
设置php-fpm启动管理文件,并让PHP在ubuntu启动时自动运行(下面地sapi是PHP5.4.0安装包中的):
如果在/etc/init.d/php-fpm不存在,那么
cp -f sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
update-rc.d -f php-fpm defaults
然后如果你运行php的话,还的戴上路径,但是你可以修改/etc/profile,在文件的最后加上这样一 句:export PATH="$PATH:/usr/local/php/bin",这里解释一下,php是安装在了/usr/local/下面,然后 你没加这一句的话,你的这样运行php,/usr/local/php/bin/php ,加上这句话之后,你就可以直接输入php运行。
在这里说一下,在启动php-fpm的时候,总是报 “fastcgi [pool www] cannot get gid for group ‘nobody’”,然后我找到
/usr/local/php/etc/php-fpm.conf,搜索nobody,把这里修改成有效的用户和用户组,?注意,你不知道的话,可以输入whoami ,察看你当前是谁,然后察看
/etc/group,看看属于哪个组。把下面这两句修改就可以了:
user =nobody group=nobody
注,nginx会自动加载php5.3版本,这时需要更改配置
vim /etc/init.d/php5-fpm,用最终的替换箭头上的
伪静态
http://blog.licess.org/nginx_rewrite/
rewrite ^/1.html$ /1.txt last;
rewrite ^/hello_(\d*)_(\d*).html /hello.php?id=$1&classid=$2 last;
参考:
http://www.jb51.net/article/26597.htm
http://hi.baidu.com/_you_yan/item/0a344615f31e7e731009b529
http://lvjian.blog.51cto.com/1304372/577637