LNMP环境搭建
1. 必要yum源更新
yum -y install gcc gcc-c++ cmake ncurses ncurses-devel bison libxml2-devel python-devel jpeg-devl libtool libXpm-devel libjpeg-devel
yum -y install "libtool*"
2. openssl 安装
tar -zxvf openssl
./config --prefix=/usr/local/openssl
make
make install
openssl version 查看版本号
CURL安装注意
./configure --prefix=/usr/local/curl --with-gssapi --enable-tls-srp --with-libmetalink #一定注意参数 这样才支持https
3. nginx的安装
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-openssl=/mini/openssl-1.0.2e --with-pcre=/mini/pcre-8.37 --with-zlib=/mini/zlib-1.2.3
注意:后面的路径是源码路径,不是安装路径
启动nginx: /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ps -ef | grep nginx
4.
1 编译nginx,加上参数 --with-http_stub_status_module 监控其运行状态
2 修改nginx配置文件,添加监控状态配置
在nginx.conf的server块中添加如下代码
location /nginx_status {
# Turn on nginx stats
stub_status on;
# I do not need logs for stats
access_log off;
# Security: Only allow access from 192.168.1.100 IP #
#allow 192.168.1.100;
# Send rest of the world to /dev/null #
#deny all;
}
这段代码是加在默认的server里的,
假设默认server的配置为
listen 127.0.0.1:80;
server_name 127.0.0.1;
那么访问nginx的状态,就可以通过 curl 127.0.0.1/nginx_status访问了
返回结果类似于:
Active connections: 1
server accepts handled requests
655 655 1985
Reading: 0 Writing: 1 Waiting: 0
4.php安装
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg9/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=mysqlnd --enable-soap --enable-mbstring=all --enable-sockets --with-pdo-mysql=mysqlnd --enable-opcache --enable-pcntl --with-xpm-dir=/usr/lib64/ --with-openssl --with-openssl-dir=/usr/local/openssl/ --with-curl=/usr/local/curl/
1) 安装php完成后再当前目录 复制php配置文件到指定的php配置文件目录
cp php.ini-production /usr/local/php/etc/php.ini
这里有2个配置文件
php.ini-production 是生产环境的配置 一版用它
php.ini-development 适合开发程式使用(测试用)
2)php-fpm安装配置 (在./configure的时候带 –enable-fpm参数即可开启PHP-FPM)
php-fpm 在 PHP 5.3.3之前的php来说,是一个补丁包,但之后被官方收录,在./configure的时候带 –enable-fpm参数即可开启PHP-FPM
a) #拷贝模板文件为php-fpm配置文件 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
b) #拷贝php-fpm到启动目录 cp /mini/php-5.6.17/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
c) #添加执行权限 chmod +x /etc/rc.d/init.d/php-fpm
d)#设置开机启动 chkconfig php-fpm on
e)#编辑php-fpm配置文件和 编辑nginx配置文件配置
php-fpm配置文件
vi /usr/local/php/etc/php-fpm.conf #编辑
user = nobody #默认
group = nobody #默认
pid = run/php-fpm.pid #取消前面的分号
nginx:如下
location ~ \.php$ {
root /web/test;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$; #new add pathinfo
fastcgi_param PATH_INFO $fastcgi_path_info; #new add pathinfo
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
f):启动重启fpm
/etc/rc.d/init.d/php-fpm start
/etc/rc.d/init.d/php-fpm restart
如果显示 Starting php-fpm done 表示启动成功
还要重启nginx
php7配置安装fpm
http://blog.csdn.net/hsd2012/article/details/52217686
注意nginx配置文件还有一些小配置,比如用户、网站根目录一定要和fastcgi 的root根目录相同

浙公网安备 33010602011771号