一 、 安装nginx
这个先不讲,后面补上,而且网络上有很多安装nginx的,也没什么难点,这次主要是安装PHP。
二、安装php
#下载:
wget http://bg2.php.net/distributions/php-5.6.7.tar.gz
#解压
tar zxvf php-5.6.7.tar.gz
#编译
./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=/usr/local/mysql --enable-mbstring --with-mysqli=/usr/bin/mysql_config
会出现的报错:
1)xml2-config not found. Please check your libxml2 installation
检查是否安装了libxm包
[root@XKWB3403 php-5.3.8]# rpm -qa |grep libxml2
libxml2-2.6.26-2.1.12
libxml2-python-2.6.26-2.1.12
重新安装libxml2和libxml2-devel包
yum install libxml2
yum install libxml2-devel -y
---------------------------------------------------
2)configure: error: Cannot find libmysqlclient_r under /usr/local/mysql.
Note that the MySQL client library is not bundled anymore!
解决办法:
yum安装 :mysql 、 mysql-server 和 mysql-devel
针对centos 7后面版本的mysql换成了mariadb 导致mysql-server找不到包
方法一:
yum install mariadb-server mariadb
方法二:
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server
安装成功后重启mysql服务。
# service mysqld restart
三.启动fastcgi代理模块 php-fpm
初始没有默认配置文件,用default创建一个
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
启动fpm模块
/usr/local/php/sbin/php-fpm
新版本的php-fpm已经不再支持[start|stop|restart]参数命令了,想要关闭重启,需要用kill pid管道方式
#php-fpm 启动: /usr/local/php/sbin/php-fpm #php-fpm 关闭: kill -INT `cat /var/run/php-fpm/php-fpm.pid` #php-fpm 重启: kill -USR2 `cat /var/run/php-fpm/php-fpm.pid`
注意 /var/run/php-fpm/php-fpm.pid文件路径是php-fpm.conf定义的,如果没有定义,则用 ps -ef|grep php-fpm得到master进程的pid,然后kill -INT pid
四.配置nginx
server { listen 80; server_name localhost; charset utf-8; root /u01/php/; index index.html index.htm index.php; location / { } location ~ \.php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } }
#参考链接:
https://www.cnblogs.com/kreo/p/4392173.html
https://blog.csdn.net/anljf/article/details/6981247
https://blog.csdn.net/zoucui/article/details/6045177