关于Centos生产环境编译安装LNMP和centos7安装lnmp环境的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Centos6编译安装LNMP、CentOS6.10编译安装LNMP
关于Centos生产环境编译安装LNMP和centos7安装lnmp环境的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Centos 6 编译安装LNMP、CentOS 6.10编译安装LNMP、CentOS 6.4系统下编译安装LNMP和配置PHP环境具体步骤、Centos 6.8编译安装LNMP环境(Nginx+MySQL+PHP)教程等相关知识的信息别忘了在本站进行查找喔。
本文目录一览:- Centos生产环境编译安装LNMP(centos7安装lnmp环境)
- Centos 6 编译安装LNMP
- CentOS 6.10编译安装LNMP
- CentOS 6.4系统下编译安装LNMP和配置PHP环境具体步骤
- Centos 6.8编译安装LNMP环境(Nginx+MySQL+PHP)教程
Centos生产环境编译安装LNMP(centos7安装lnmp环境)
一、环境准备
1、操作系统安装:CentOS 6.564位最小化安装。
2、配置好IP、DNS、网关、主机名
3、配置防火墙,开启80、3306端口
vim /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -mstate --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙
-A RH-Firewall-1-INPUT -mstate --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口通过防火墙
特别提示:如果这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口 。
/etc/init.d/iptables restart #最后重启防火墙使配置生效4、关闭SELinux
vi /etc/selinux/configurations
#SELINUX=enforcing #注释掉#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0#使配置立即生效
二、系统约定
硬盘分区:50G(/boot 200M /swap8192M /)+100G(/opt)
软件源代码包存放位置:/opt/local/src
源码包编译安装位置:/opt/local/软件名
数据库数据文件存储路径/opt/local/MysqL/var
三、软件包下载
1、下载Nginx(目前稳定版):http://Nginx.org/download/Nginx-1.4.4.tar.gz
2、下载pcre (支持Nginx伪静态):ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz
3、下载MysqL:http://cdn.MysqL.com/Downloads/MysqL-5.5/MysqL-5.5.35.tar.gz
4、下载PHP:http://cn2.PHP.net/distributions/PHP-5.5.7.tar.gz
5、下载cmake(MysqL编译工具):http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
6、下载libmcrypt(PHPlibmcrypt模块):http://nchc.dl.sourceforge.net/project/mcrypt/libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
7、下载GD库安装包(PHP页面图片验证码支持):https://PHPsqq.googlecode.com/files/gd-2.0.36RC1.tar.gz
将以上软件包上传到/opt/local/src目录
四、安装编译工具及库文件
使用CentOS yum命令一键安装
yum install -y make apr* autoconf automake curl curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng* PHP-common PHP-gd gettext gettext-devel ncurses* libtool* libxml2 libxml2-devel patch policycoreutils bison
五、软件安装篇
1、安装cmake
cd /opt/local/src
tar zxvf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure --prefix=/opt/local/cmake
make #编译
make install #安装
vim /etc/profile 在path路径中增加cmake执行文件路径
export PATH=$PATH:/opt/local/cmake/bin
source /etc/profile使配置立即生效
2、安装pcre
cd /opt/local/src
mkdir /usr/local/pcre #创建安装目录
tar zxvf pcre-8.34.tar.gz
cd pcre-8.34
./configure --prefix=/opt/local/pcre#配置
make && make install
3、安装libmcrypt
cd /opt/local/src
tar zxvf libmcrypt-2.5.8.tar.gz #解压
cd libmcrypt-2.5.8#进入目录
./configure #配置
make #编译
make install #安装
4、安装gd库
cd /opt/local/src
tar zxvf gd-2.0.36RC1.tar.gz
cd gd-2.0.36RC1
./configure --enable-m4_pattern_allow ―prefix=/opt/local/gd --with-jpeg=/usr/lib --with-png=/usr/lib --with-xpm=/usr/lib --with-freetype=/usr/lib --with-fontconfig=/usr/lib#配置
make #编译
make install #安装5、安装MysqL
groupadd MysqL #添加MysqL组
useradd -g MysqL MysqL -s /bin/false #创建用户MysqL并加入到MysqL组,不允许MysqL用户直接登录系统mkdir -p /opt/data/MysqL/var #创建MysqL数据库存放目录chown -R MysqL:MysqL /opt/data/MysqL/var #设置MysqL数据库目录权限
cd /opt/local/src
tar zxvf MysqL-5.5.35.tar.gz #解压
cd MysqL-5.5.35
cmake . -DCMAKE_INSTALL_PREFIX=/opt/local/MysqL -DMysqL_DATADIR=/opt/data/MysqL/var -DSYSconfdIR=/etc#配置
make #编译
make install #安装
cd /opt/local/MysqL
cp ./support-files/my-huge.cnf /etc/my.cnf #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
vi /etc/my.cnf #编辑配置文件,在 [MysqLd] 部分增加
datadir = /opt/data/MysqL/var#添加MysqL数据库路径
./scripts/MysqL_install_db --user=MysqL #生成MysqL系统数据库
cp ./support-files/MysqL.server /etc/rc.d/init.d/MysqLd #把MysqL加入系统启动chmod755 /etc/init.d/MysqLd #增加执行权限
chkconfig MysqLd on #加入开机启动
vi /etc/rc.d/init.d/MysqLd #编辑
basedir = /opt/local/MysqL #MysqL程序安装路径
datadir = /opt/local/MysqL/var #MysqL数据库存放目录
service MysqLd start #启动
vi /etc/profile #把MysqL服务加入系统环境变量:在最后添加下面这一行
export PATH=$PATH:/opt/local/cmake/bin:/opt/local/MysqL/bin
source /etc/profile #使配置立即生效
mkdir /var/lib/MysqL#创建目录
ln -s /tmp/MysqL.sock /var/lib/MysqL/MysqL.sock #添加软链接
MysqL_secure_installation #设置MysqL密码,根据提示按Y 回车输入2次密码
/opt/local/MysqL/bin/MysqLadmin -u root -p password "123456"#或者直接修改密码
到此,MysqL安装完成!
6、安装 Nginx
cd /opt/local/src
groupadd www #添加www组
useradd -g www www -s /bin/false #创建Nginx运行账户www并加入到www组,不允许www用户直接登录系统
tar zxvf Nginx-1.4.4.tar.gz
cd Nginx-1.4.4
./configure --prefix=/opt/local/Nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/opt/local/src/pcre-8.31
注意:--with-pcre=/opt/local/src/pcre-8.34指向的是源码包解压的路径,而不是安装的路径,否则会报错
make
make install
/opt/local/Nginx/sbin/Nginx #启动Nginx
设置Nginx开启启动
vi /etc/rc.d/init.d/Nginx #编辑启动文件添加下面内容
=======================================================
#!/bin/bash# Nginx Startup script for the Nginx HTTP Server# it is v.0.0.2 version.# chkconfig: - 85 15# description: Nginx is a high-performance web and proxy server.# It has a lot of features,but it's not for everyone.# processname: Nginx# pidfile: /var/run/Nginx.pid# config: /usr/local/Nginx/conf/Nginx.conf
Nginxd=/opt/local/Nginx/sbin/Nginx
Nginx_config=/opt/local/Nginx/conf/Nginx.conf
Nginx_pid=/opt/local/Nginx/logs/Nginx.pid
RETVAL=0
prog="Nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $Nginxd ] || exit 0
# Start Nginx daemons functions.
start() {
if [ -e $Nginx_pid ];then
echo "Nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $Nginxd -c ${Nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/Nginx
return $RETVAL
}
# Stop Nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $Nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/Nginx /usr/local/Nginx/logs/Nginx.pid
}
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${Nginx_pid}`
killproc $Nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"exit1
esac
exit$RETVAL
=======================================================
:wq! #保存退出chmod775 /etc/rc.d/init.d/Nginx #赋予文件执行权限
chkconfig Nginx on #设置开机启动
/etc/rc.d/init.d/Nginx restart #重新启动Nginx
service Nginx restart
=======================================================
7、安装PHP
cd /opt/local/src
tar -zvxf PHP-5.5.7.tar.gz
cd PHP-5.5.7.
./configure --prefix=/opt/local/PHP5 --with-config-file-path=/opt/local/PHP5/etc --with-MysqL=/opt/local/MysqL --with-MysqL-sock=/tmp/MysqL.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --with-jpeg-dir --with-freetype-dir
make #编译
make install #安装
cp PHP.ini-production /opt/local/PHP5/etc/PHP.ini #复制PHP配置文件到安装目录
rm -rf /etc/PHP.ini #删除系统自带配置文件
ln -s /opt/local/PHP5/etc/PHP.ini /etc/PHP.ini #添加软链接
cp /opt/local/PHP5/etc/PHP-fpm.conf.default /opt/local/PHP5/etc/PHP-fpm.conf #拷贝模板文件为PHP-fpm配置文件
vi /opt/local/PHP5/etc/PHP-fpm.conf #编辑
user = www #设置PHP-fpm运行账号为www
group = www #设置PHP-fpm运行组为www
pid = run/PHP-fpm.pid #取消前面的分号
设置 PHP-fpm开机启动
cp /opt/local/src/PHP-5.5.7/sapi/fpm/init.d.PHP-fpm /etc/rc.d/init.d/PHP-fpm #拷贝PHP-fpm到启动目录chmod +x /etc/rc.d/init.d/PHP-fpm #添加执行权限
chkconfig PHP-fpm on #设置开机启动
vi /opt/local/PHP5/etc/PHP.ini #编辑配置文件
找到:disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用
找到:;date.timezone =
修改为:date.timezone = PRC #设置时区
找到:expose_PHP = On
修改为:expose_PHP = OFF #禁止显示PHP版本的信息
找到:short_open_tag = Off
修改为:short_open_tag = ON #支持PHP短标签
八、配置Nginx支持PHP
vi /opt/local/Nginx/conf/Nginx.conf
修改/opt/local/Nginx/conf/Nginx.conf 配置文件,需做如下修改
user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/opt/local/PHP/etc/PHP-fpm.conf中的user,group配置相同,否则PHP运行出错
user www www;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen80;
server_name localhost;
location / {
root html;
indexindex.PHP index.html index.htm;
}
location ~ \.PHP$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
/etc/init.d/Nginx restart #重启Nginx
六、测试篇
cd /opt/local/Nginx/html/ #进入Nginx默认网站根目录
rm -rf /opt/local/Nginx/html/* #删除默认测试页
vi index.PHP #新建index.PHP文件
PHPinfo();
?>
:wq! #保存退出chown www.www /opt/local/Nginx/html/ -R #设置目录所有者chmod700 /opt/local/Nginx/html/ -R #设置目录权限
七、其它说明
服务器相关操作命令
service Nginx restart #重启Nginx
service MysqLd restart #重启MysqL
/usr/local/PHP/sbin/PHP-fpm #启动PHP-fpm
/etc/rc.d/init.d/PHP-fpm restart #重启PHP-fpm
/etc/rc.d/init.d/PHP-fpm stop #停止PHP-fpm
/etc/rc.d/init.d/PHP-fpm start #启动PHP-fpm
Nginx默认站点目录是:/opt/local/Nginx/html/
权限设置:chown www.www /opt/local/Nginx/html/ -R
MysqL数据库目录是:/opt/local/MysqL/var
权限设置:chown MysqL.MysqL -R /opt/local/MysqL/var
八、安全优化
sherwin@rocnic~$ssh root@172.16.134.141
root@172.16.134.141's password:
Last login: Sat Jan 18 12:11:57 2014 from 172.16.134.1
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
[root@dev01 ~]# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE=UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
Centos 6 编译安装LNMP
搭建环境:Centos 6.8,Nginx 1.9.14,MysqL 5.6.23,PHP 5.6.17
一、目的:LNMP如今已成为主流的web服务器搭建方案,公司内部的ECstore,discuz,计划用来替代nagios+check_mk监控平台的Zabbix。均基于LNMP。本次单机LNMP搭建为后续全面了解电商集群做准备,顺便记录搭建过程,作为以后搭建环境的参考。
二、LNMP安装环境准备:
关闭防火墙及selinux
serviceiptablesstop chkconfigiptablesoff setenforce0 vi/etc/sysconfig/selinux SELINUX=disabled#enforcing改为disabled
依赖包安装
yum-yinstallgccgcc-c++autoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-developenldapopenldap-developenldap-clientsopenldap-serversmakelibtool*gittreebisonpcre-develperlgdgd-devel
安装libiconv(支持编码转换为函数)
tarxflibiconv-1.14.tar.gz cdlibiconv-1.14/ ./configure--prefix=/usr/local make&&makeinstall
安装libmcrypt (加密算法扩展库,支持DES,3DES,RIJNDAEL,Twofish,IDEA,GOST,CAST-256,ARCFOUR,SERPENT,SAFER+等算法)
tarxflibmcrypt-2.5.8.tar.gz cdlibmcrypt-2.5.8 ./configure make&&makeinstall cdlibltdl/ ./configure--enable-ltdl-install#加载动态库 make&&makeinstall
安装mhash(Mhash是基于离散数学原理的不可逆向的PHP加密方式扩展库,其在默认情况下不开启。 mhash的可以用于创建校验数值,消息摘要,消息认证码,以及无需原文的关键信息保存)
tarxfmhash-0.9.9.9.tar.bz2 cdmhash-0.9.9.9 ./configure make&&makeinstall
安装mcript(mcrypt 是 PHP 里面重要的加密支持扩展库,Mcrypt扩展库可以实现加密解密功能,就是既能将明文加密,也可以密文还原。)
cd/usr/local/src tarzxvfmcrypt-2.6.8.tar.gz cdmcrypt-2.6.8/ exportLD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH#暂时生效 ./configure make&&makeinstall
亦可以通过以下两种方法增加库文件
ln-s/usr/local/lib/libmcrypt.la/usr/lib/libmcrypt.la ln-s/usr/local/lib/libmcrypt.so/usr/lib/libmcrypt.so ln-s/usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4 ln-s/usr/local/lib/libmcrypt.so.4.4.8/usr/lib/libmcrypt.so.4.4.8 ln-s/usr/local/lib/libmhash.a/usr/lib/libmhash.a ln-s/usr/local/lib/libmhash.la/usr/lib/libmhash.la ln-s/usr/local/lib/libmhash.so/usr/lib/libmhash.so ln-s/usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2 ln-s/usr/local/lib/libmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1 ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
vim/etc/ld.so.conf /usr/local/lib/ ldconfig
安装cmake (MysqL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具)
tarxfcmake-3.4.1.tar.gz cdcmake-3.4.1 ./bootstrap make&&makeinstall
注:一起解压所有文件可采用:find /usr/local/src/*.tar.gz -exec tar xf {} \;
三、MysqL编译安装
新增MysqL用户
groupadd-rMysqL useradd-r-gMysqLMysqL
新建MysqL所需目录
mkdir-p/usr/local/MysqL mkdir-p/data/MysqLdb
编译安装
tarxfmysql-5.6.23.tar.gz cdmysql-5.6.23 cmake-DCMAKE_INSTALL_PREFIX=/usr/local/MysqL-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DMysqL_DATADIR=/data/MysqLdb-DMysqL_TCP_PORT=3306-DENABLE_DOWNLOADS=1-DSYSconfdIR=/etc-DWITH_SSL=system-DWITH_ZLIB=system-DWITH_LIBWRAP=0 make&&makeinstall
修改MysqL目录权限
cd/usr/local/MysqL chown-RMysqL:MysqL. cd/data/MysqLdb chown-RMysqL:MysqL.
初始化MysqL数据库
cd/usr/local/MysqL ./scripts/MysqL_install_db--user=MysqL--datadir=/data/MysqLdb
编译修改/etc/my.cnf
[MysqL] #CLIENT# port=3306 socket=/data/MysqLdb/MysqL.sock [MysqLd] #GENERAL# user=MysqL default-storage-engine=InnoDB socket=/data/MysqLdb/MysqL.sock pid-file=/data/MysqLdb/MysqL.pid #MyISAM# key-buffer-size=32M myisam-recover=FORCE,BACKUP #SAFETY# max-allowed-packet=16M max-connect-errors=1000000 #DATASTORAGE# datadir=/data/MysqLdb/ #BINARYLOGGING# log-bin=/data/MysqLdb/MysqL-bin expire-logs-days=14 sync-binlog=1 #REPLICATION# skip-slave-start=1 relay-log=/data/MysqLdb/relay-bin slave-net-timeout=60 #CACHESANDLIMITS# tmp-table-size=32M max-heap-table-size=32M query-cache-type=0 query-cache-size=0 max-connections=500 thread-cache-size=50 open-files-limit=65535 table-deFinition-cache=4096 table-open-cache=4096 #INNODB# innodb-flush-method=O_DIRECT innodb-log-files-in-group=2 innodb-log-file-size=64M innodb-flush-log-at-trx-commit=1 innodb-file-per-table=1 innodb-buffer-pool-size=592M #LOGGING# log-error=/data/MysqLdb/MysqL-error.log log-queries-not-using-indexes=1 slow-query-log=1 slow-query-log-file=/data/MysqLdb/MysqL-slow.log
复制MysqL启动文件及其命令加入PATH
cpsupport-files/MysqL.server/etc/init.d/MysqLd vim/etc/profile.d/MysqL.sh PATH=/usr/local/MysqL/bin:/usr/local/MysqL/lib:$PATH exportPATH source/etc/profile.d/MysqL.sh
启动MysqL并增加启动项
serviceMysqLdstart chkconfigMysqLdon
设置MysqL登录权限
dropuser''@localhost; dropuser''@hostname; updateMysqL.usersetpassword=password('*******'); flushprivileges;
四、Nginx编译安装
新增Nginx用户
groupadd-rNginx useradd-gNginx-rNginx
创建所需要目录
mkdir-pv/var/tmp/Nginx/client
编译安装Nginx
tarxfNginx-1.9.14.tar.gz cdNginx-1.9.14 ./configure--prefix=/usr/local/Nginx--sbin-path=/usr/local/Nginx/sbin/Nginx--conf-path=/etc/Nginx/Nginx.conf--error-log-path=/var/log/Nginx/error.log--http-log-path=/var/log/Nginx/access.log--pid-path=/var/run/Nginx/Nginx.pid--lock-path=/var/lock/Nginx.lock--user=Nginx--group=Nginx--with-http_ssl_module--with-http_flv_module--with-http_stub_status_module--with-http_gzip_static_module--http-client-body-temp-path=/var/tmp/Nginx/client/--http-proxy-temp-path=/var/tmp/Nginx/proxy/--http-fastcgi-temp-path=/var/tmp/Nginx/fcgi/--http-uwsgi-temp-path=/var/tmp/Nginx/uwsgi--http-scgi-temp-path=/var/tmp/Nginx/scgi--with-pcre make&&makeinstall
编辑启动脚本
vim/etc/rc.d/init.d/Nginx #!/bin/sh # #Nginx-thisscriptstartsandstopstheNginxdaemon # #chkconfig:-8515 #description:NginxisanHTTP(S)server,HTTP(S)reverse\ #proxyandIMAP/POP3proxyserver #processname:Nginx #config:/etc/Nginx/Nginx.conf #config:/etc/sysconfig/Nginx #pidfile:/var/run/Nginx.pid #Sourcefunctionlibrary. ./etc/rc.d/init.d/functions #Sourcenetworkingconfiguration. ./etc/sysconfig/network #Checkthatnetworkingisup. ["$NETWORKING"="no"]&&exit0 Nginx="/usr/local/Nginx/sbin/Nginx" prog=$(basename$Nginx) Nginx_CONF_FILE="/etc/Nginx/Nginx.conf" [-f/etc/sysconfig/Nginx]&&./etc/sysconfig/Nginx lockfile=/var/lock/subsys/Nginx make_dirs(){ #makerequireddirectories user=`Nginx-V2>&1|grep"configurearguments:"|sed's/[^*]*--user=\([^]*\).*/\1/g'-` options=`$Nginx-V2>&1|grep'configurearguments:'` foroptin$options;do if[`echo$opt|grep'.*-temp-path'`];then value=`echo$opt|cut-d"="-f2` if[!-d"$value"];then #echo"creating"$value mkdir-p$value&&chown-R$user$value fi fi done } start(){ [-x$Nginx]||exit5 [-f$Nginx_CONF_FILE]||exit6 make_dirs echo-n$"Starting$prog:" daemon$Nginx-c$Nginx_CONF_FILE retval=$? echo [$retval-eq0]&&touch$lockfile return$retval } stop(){ echo-n$"Stopping$prog:" killproc$prog-QUIT retval=$? echo [$retval-eq0]&&rm-f$lockfile return$retval } restart(){ configtest||return$? stop sleep1 start } reload(){ configtest||return$? echo-n$"Reloading$prog:" killproc$Nginx-HUP RETVAL=$? echo } force_reload(){ restart } configtest(){ $Nginx-t-c$Nginx_CONF_FILE } rh_status(){ status$prog } rh_status_q(){ rh_status>/dev/null2>&1 } case"$1"in start) rh_status_q&&exit0 $1 ;; stop) rh_status_q||exit0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q||exit7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q||exit0 ;; *) echo$"Usage:$0{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit2 esac
设置开机启动并启动服务
chmod+x/etc/rc.d/init.d/Nginx chkconfig--addNginx chkconfigNginxon serviceNginxstart
五、PHP编译安装
解决PHP安装的库依赖关系
cp-frp/usr/lib64/libldaP*/usr/lib/ echo/usr/local/MysqL/lib>>/etc/ld.so.conf.d/MysqL-x86_64.conf ldconfig-v
编译安装PHP
tarxfPHP-5.6.17.tar.gz cdPHP-5.6.17 ./configure--prefix=/usr/local/PHP--with-MysqL=/usr/local/MysqL--with-MysqLi=/usr/local/MysqL/bin/MysqL_config--with-iconv-dir=/usr/local--with-openssl--enable-mbstring--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml--disable-rpath--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--enable-mbregex--enable-mbstring--with-gd--enable-gd-native-ttf--with-mhash--enable-pcntl--enable-sockets--with-mcrypt--with-ldap--with-ldap-sasl--with-xmlrpc--enable-zip--enable-soap--with-bz2--with-config-file-path=/etc--enable-fpm--with-config-file-scan-dir=/etc/PHP.d--enable-maintainer-zts makeZEND_EXTRA_LIBS='-liconv' makeinstall
复制PHP配置文件
cpPHP.ini-production/etc/PHP.ini
复制PHP-fpm配置文件
cp/usr/local/PHP/etc/PHP-fpm.conf.default/usr/local/PHP/etc/PHP-fpm.conf
设置PHP-fpm启动脚本并开机启动
cpsapi/fpm/init.d.PHP-fpm/etc/rc.d/init.d/PHP-fpm chmod+x/etc/rc.d/init.d/PHP-fpm chkconfig--addPHP-fpm chkconfigPHP-fpmon servicePHP-fpmstart
六、web功能基本实现
Nginx,PHP功能整合
vim/etc/Nginx/Nginx.conf #location~\.PHP${ #roothtml; #fastcgi_pass127.0.0.1:9000; #fastcgi_indexindex.PHP; #fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name; #includefastcgi_params; #} #修改为 location~\.PHP${ fastcgi_pass127.0.0.1:9000; fastcgi_indexindex.PHP; fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name; includefastcgi_params; }
增加LNMP测试页面
vim/usr/local/Nginx/html/test.PHP <?PHP $link=MysqL_connect('127.0.0.1','root','you_passwd'); if($link) echo"It'sOK,Frank"; else echo"Failed,Frank"; MysqL_close; PHPinfo(); ?>
Nginx重载
serviceNginxreload
访问http://ip/test.php,LNMP测试成功。
七、后记
从去年底开始,LAMP,LNMP断断续续搭建过多次,搭建时磕磕碰碰,完成后就会忘记,估计是基础不牢的原因。虽然本次搭建中间也有些许不顺,但决定写博文之后,还是有点小压力,前前后后验证了两遍,还是可以保证可行性的。本次Nginx,PHP的配置优化及插件均未涉及,后续博文中将陆续补上。
CentOS 6.10编译安装LNMP
一、前期准备
1.服务器以最小化方式安装CentOS 6.9或CentOS 6.10
2.配置本地源及安装epel源
3.#yum install kernel kernel-devel,再重启服务器。 //升级内核
4.#yum update //系统升级。若为CentOS6.9,则升级后为CentOS 6.10
5.编译安装gcc-4.8.5, // 请参考https://blog.51cto.com/191226139/2066137
6.编译安装cmake-3.10.2,//请参考https://blog.51cto.com/191226139/2066186
7.安装ntpd时间服务器
8.Yum remove packages…
httpd httpd-tools MysqL MysqL-libs PHP-MysqL PHP-cli PHP-gd PHP-common PHP
特别执行#yum remove MysqL-libs //将删除crontabs,后面再安装crontabs,记得开启crond服务
9.Yum installing dependent packages…
flex bison file libtool libtool-ltdl autoconf kernel-devel patch wget crontabs libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel unzip tar bzip2 bzip2-devel libzip libzip-devel libevent libevent-devel ncurses ncurses-devel curl libcurl-devel libcurl e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal gettext gettext-devel gmp-devel pspell-devel libcap diffutils ca-certificates net-tools libc-client libc-client-devel psmisc libXpm-devel git c-ares-devel libicu-devel libxslt libxslt-devel xz expat-devel libaio-devel rpcgen libtirpc-devel perl bison bison-devel libcurl-devel libcurl libarchive-devel boost boost-devel lsof pcre pcre-devel
libmcrypt libmcrypt-devel libvpx mhash t1lib
二 编译安装LNMP
(一)编译安装Mariadb
1.安装依赖包
#yum install ncurses-devel libaio-devel openssl-devel -y
#cmake --version
cmake version 3.10.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
2.创建用于MysqL的组和账号
#groupadd -r MysqL
#useradd -r -g MysqL -s /sbin/nologin -M MysqL
3.编译安装mariadb
#cd /data/lnmpsoft
ls
mariadb-10.2.19.tar.gz
tar -zxvf mariadb-10.2.19.tar.gz -C /usr/local/src
#mkdir /usr/local/src/db-build
#mkdir /usr/local/mariadb-10.2.14
#chown root:root /usr/local/mariadb-10.2.14
#mkdir /var/run/MysqL
#chown MysqL:MysqL /var/run/MysqL
#cd /usr/local/src/db-build
#cmake /usr/local/src/mariadb-10.2.19
-DCMAKE_INSTALL_PREFIX=/usr/local/mariadb-10.2.19 \ -DMysqL_UNIX_ADDR=/var/run/MysqL/MysqL.sock
-DMysqL_TCP_PORT=3306
-DMysqL_USER=MysqL
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
-DENABLED_LOCAL_INFILE=1
-DENABLE_DOWNLOADS=1
-DEXTRA_CHARSETS=all
-DSYSconfdIR=/etc
-DWITHOUT_TOKUDB=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MRG_MyISAM_STORAGE_ENGINE=1
-DWITH_CSV_STORAGE_ENGINE=1
-DWITH_SEQUENCE_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_ARIA_STORAGE_ENGINE=1
-DWITH_PERFORMANCE_SCHEMA_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DWITH_SSL=system
-DWITH_ZLIB=system
-DWITH_LOBWRAP=0
-DMysqL_MAINTAINER_MODE=0
-DWITH_DEBUG=0
此处为编译mariadb,可在MysqL-bianyi中复制。
#make && make install
#ln -s /usr/local/mariadb-10.2.19 /usr/local/MysqL
4.添加PATH至环境变量中
#echo ‘PATH=/usr/local/MysqL/bin:$PATH’ >> /etc/profile.d/MysqL.sh
检查文件
#cat /etc/profile.d/MysqL.sh
加载环境变量文件并检查
#source /etc/profile.d/MysqL.sh
#echo $PATH
检查MysqL版本
#MysqL -V
MysqL Ver 15.1 distrib 10.2.19-MariaDB, for Linux (x86_64) using readline 5.1
5.创建数据库存放文件夹并修改权限
#mkdir -pv /data/MysqLdb/3306/{log,data,pid,tmp}
chown -R MysqL:MysqL /data/MysqLdb/
chmod -R 770 /data/MysqLdb/
6.复制及修改配置文件my.cnf
cp /usr/local/MysqL/support-files/my-large.cnf /etc/my.cnf
vim /etc/my.cnf
[MysqLd]
port = 3306
socket = /var/run/MysqL/MysqL.sock
pid-file = /data/MysqLdb/3306/pid/MysqL.pid
datadir = /data/MysqLdb/3306/data
tmpdir = /data/MysqLdb/3306/tmp
innodb_file_per_table = 1
skip_name_resolve = 1
log-error = /data/MysqLdb/3306/log/error.log
7.安装数据库相关文件
#cd /usr/local/MysqL/
查看下安装程序的安装参数
#/usr/local/MysqL/scripts/MysqL_install_db --help
#./scripts/./MysqL_install_db --user=MysqL --basedir=/usr/local/mariadb-10.2.19 --datadir=/data/MysqLdb/3306/data
[Warning] ‘THREAD_CONCURRENCY’ is deprecated and will be removed in a future release.
OK
To start MysqLd at boot time you have to copy
support-files/MysqL.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
‘/usr/local/mariadb-10.2.19/bin/MysqLadmin’ -u root password ‘new-password’
‘/usr/local/mariadb-10.2.19/bin/MysqLadmin’ -u root -h dellcentos6.cqdzzx.cn password ‘new-password’
Alternatively you can run:
‘/usr/local/mariadb-10.2.19/bin/MysqL_secure_installation’
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB KNowledgebase at http://mariadb.com/kb or the
MysqL manual for more instructions.
You can start the MariaDB daemon with:
cd ‘/usr/local/mariadb-10.2.19’ ; /usr/local/mariadb-10.2.19/bin/MysqLd_safe --datadir=’/data/MysqLdb/3306/data’
You can test the MariaDB daemon with mysql-test-run.pl
cd ‘/usr/local/mariadb-10.2.19/MysqL-test’ ; perl mysql-test-run.pl
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MysqL part at:
http://dev.mysql.com
Consider joining MariaDB’s strong and vibrant community:
https://mariadb.org/get-involved/
8.复制启动服务脚本至/etc/init.d目录并启动
#cp /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqLd
#chkconfig --add MysqLd
#chkconfig MysqLd on
#service MysqLd start
Starting MariaDB.190521 15:07:45 MysqLd_safe Logging to ‘/data/MysqLdb/3306/log/error.log’.
190521 15:07:45 MysqLd_safe Starting MysqLd daemon with databases from /data/MysqLdb/3306/data
SUCCESS!
9.进行安全配置
#/usr/local/MysqL/bin/MysqL_secure_installation
Enter current password for root 默认为空
Set root password 设置MysqL root密码
Remove anonymous users 是否移除匿名用户登录
disallow root login remotely 是否禁止root远程登录
Remove test database and access to it? 是否移除test数据和test账号
Reload privilege tables Now? 是否立即更新权限
Thanks for using MariaDB!
(二)编译安装Nginx
1.安装依赖包
yum install pcre pcre-devel openssl openssl-devel zlib zlib-devel
2.创建用于Nginx,PHP的组和账号
groupadd -r www
useradd -r -g www -s /sbin/nologin -M www
3.编译安装Nginx
mkdir -p /usr/local/Nginx
#chown root:root /usr/local/Nginx
#mkdir -pv /var/tmp/Nginx/{client_body_temp,proxy_temp,
fcgi_temp,uwsgi_temp,scgi_temp}
#cd /var/tmp
chown -R www:www /var/tmp/Nginx
#cd /usr/local/src/Nginx-1.14.0
#./configure
–prefix=/usr/local/Nginx
–user=www
–group=www
–with-http_stub_status_module
–with-http_ssl_module
–with-http_v2_module
–with-http_flv_module
–with-http_mp4_module
–with-http_gzip_static_module
–with-http_sub_module
–with-stream
–with-stream_ssl_module
–http-client-body-temp-path=/var/tmp/Nginx/client_body_temp/
–http-proxy-temp-path=/var/tmp/Nginx/proxy_temp/
–http-fastcgi-temp-path=/var/tmp/Nginx/fcgi_temp/
–http-uwsgi-temp-path=/var/tmp/Nginx/uwsgi_temp/
–http-scgi-temp-path=/var/tmp/Nginx/scgi_temp/
–with-openssl=
–with-pcre
4.加载环境变量文件并检查
echo ‘PATH=/usr/local/Nginx/sbin:$PATH’’>>/etc/profile.d/Nginx.sh
source /etc/profile.d/Nginx.sh
#Nginx -t
Nginx: the configuration file /usr/local/Nginx/conf/Nginx.conf Syntax is ok
Nginx: configuration file /usr/local/Nginx/conf/Nginx.conf test is successful
5.启动Nginx
#Nginx -c /usr/local/Nginx/conf/Nginx.conf
echo “/usr/local/Nginx/sbin/Nginx -c /usr/local/Nginx/conf/Nginx…conf”>>/etc/rc.d/rc.local //添加开机启动
6.iptables开启80端口
(三)编译安装PHP
1.安装依赖库
#yum install gd curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel libXpm-devel mhash libmcrypt libmcrypt-devel libvpx t1lib libicu-devel glibc
2.编译安装PHP-7.1.29
#cd /usr/local/src
#tar -zxvf PHP-7.1.29.tar.gz -C /usr/local/src
#mkdir /usr/local/PHP7
#cd /usr/local/src/PHP-7.1.29
#./configure --prefix=/usr/local/PHP7
–with-config-file-path=/usr/local/PHP7/etc
–with-config-file-scan-dir=/usr/local/PHP7/conf.d
–with-MysqL-sock=/var/run/MysqL/MysqL.sock
–enable-fpm
–with-fpm-user=www
–with-fpm-group=www
–enable-MysqLnd
–with-MysqLi=MysqLnd
–with-pdo-MysqL=MysqLnd
–with-iconv-dir=/usr/local/libiconv
–with-freetype-dir=
–with-jpeg-dir
–with-png-dir
–with-zlib
–with-libxml-dir=
–enable-xml
–disable-rpath
–enable-bcmath
–enable-shmop
–enable-sysvsem
–enable-inline-optimization
–with-curl
–enable-mbregex
–enable-mbstring
–enable-intl
–with-mcrypt
–enable-ftp
–with-gd
–enable-gd-native-ttf
–with-openssl
–with-mhash
–enable-pcntl
–enable-sockets
–with-xmlrpc
–enable-zip
–enable-soap
–with-gettext
–enable-opcache
–with-xsl
–enable-shared
–enable-libxml
–enable-session
–with-xpm-dir=
make && make install
3.配置PHP
⑴.cp /usr/local/src/PHP-7.1.29/PHP.ini-production /usr/local/PHP7/etc/PHP.ini
⑵.vim /usr/local/PHP7/etc/PHP.ini
①找到cgi.fix_pathinfo配置项并修改为0
cgi.fix_pathinfo=0
②找到 extension_dir
修改扩展目录位置并修改如下
extension_dir = “/usr/local/PHP7/lib/PHP/extensions/no-debug-non-zts-20160303/”
③找到 timezone
修改时区如下:
date.timezone = PRC
PRC就是英文People’s Republic of China,中华人民共和国
④开启OPcache
跳转到文件的最后一行(shift+G), 输入以下内容:
zend_extension=opcache.so
⑤修改session的目录配置
#mkdir -p /var/lib/PHP7/session
#chown -R www:www /var/lib/PHP7/session
vim /usr/local/PHP7/etc/PHP.ini
找到 session.save_path
修改为如下内容:
session.save_path = “/var/lib/PHP7/session”
⑶添加PHP-fpm管理相关的配置文件到系统配置目录/etc/init.d
①# cp /usr/local/src/PHP-7.1.29/sapi/fpm/init.d.PHP-fpm /etc/init.d/PHP-fpm
#chmod 755 /etc/init.d/PHP-fpm
②cp /usr/local/PHP7/etc/PHP-fpm.conf.default /usr/local/PHP7/etc/PHP-fpm.conf
③cp /usr/local/PHP7/etc/PHP-fpm.d/www.conf.default
/usr/local/PHP7/etc/PHP-fpm.d/www.conf
⑷添加PHP系统环境变量
vim /etc/profile.d/PHP.sh
添加内容如下:
export PATH=PATH:/usr/local/php7/bin/:/usr/local/php7/sbin/或PATH=/usr/local/php7/bin/:/usr/local/php7/sbin/:PATH
source /etc/profile.d/PHP.sh 使用source立即生效刚刚添加的PHP环境变量
⑸设置PHP开机启动
#chkconfig --add PHP-fpm
#chkconfig PHP-fpm on
#service PHP-fpm start
CentOS 6.4系统下编译安装LNMP和配置PHP环境具体步骤
一、准备工作
上pkgs.org下载rmpforge。rpmforge是一个第三方yum源。

选择相应的版本下载安装。
// 安装成功后,清空yum list 并 重新获取
[root@pangou Desktop]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: base extras rpmforge updates
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@pangou Desktop]# yum -y list
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
// ......
卸载已存在的apache服务和php
[root@pangou Desktop]# yum remove httpd php*
安装development Tools
[root@pangou Desktop]# yum -y groupinstall "Development Tools"
二、安装nginx
创建nginx目录,下载nginx,并解压缩
[root@pangou Downloads]# mkdir nginx
[root@pangou Downloads]# cd nginx/
[root@pangou nginx]# pwd
/root/Downloads/nginx
[root@pangou nginx]# wget http://nginx.org/download/nginx-1.4.0.tar.gz
--2013-04-30 23:13:44-- http://nginx.org/download/nginx-1.4.0.tar.gz
Resolving nginx.org... 206.251.255.63
Connecting to nginx.org|206.251.255.63|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 773451 (755K) [application/octet-stream]
Saving to: “nginx-1.4.0.tar.gz”
100%[================================================================>] 773,451 184K/s in 4.5s
2013-04-30 23:13:48 (166 KB/s) - “nginx-1.4.0.tar.gz” saved [773451/773451]
[root@pangou nginx]# ls
nginx-1.4.0.tar.gz
[root@pangou nginx]# tar -zxvf nginx-1.4.0.tar.gz
[root@pangou nginx]# ls
nginx-1.4.0 nginx-1.4.0.tar.gz
编译安装nginx
// 编译 安装路径/opt/nginx
[root@pangou nginx-1.4.0]# ./configure --prefix=/opt/nginx/
编译中如出现报错如:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.
就是用yum自行结局依赖关系
[root@pangou nginx-1.4.0]# yum install pcre pcre-devel
然后重新上面的编译
// 编译 安装路径/opt/nginx
[root@pangou nginx-1.4.0]# ./configure --prefix=/opt/nginx/
// 编译成功后
[root@pangou nginx-1.4.0]# make && make install
// 最后安装完成
启动nginx服务
[root@pangou nginx]# cd /opt/nginx/sbin/
[root@pangou sbin]# ./nginx
访问127.0.0.1

服务启动成功。
三、安装php
创建文件夹php,下载php,并解压缩
[root@pangou nginx-1.4.0]# cd /root/Downloads/
[root@pangou Downloads]# mkdir php
[root@pangou Downloads]# cd php/
[root@pangou php]# pwd
/root/Downloads/php
// 下载
[root@pangou php]# wget http://cn2.php.net/get/php-5.4.14.tar.gz/from/this/mirror
// 解压
[root@pangou php]# tar -zxvf php-5.4.14.tar.gz
安装依赖包
[root@pangou php]# yum install -y libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-devel libcurl-devel libmcrypt-devel
编译php
[root@pangou php]# ls
php-5.4.14 php-5.4.14.tar.gz
[root@pangou php]# cd php-5.4.14
[root@pangou php-5.4.14]# pwd
/root/Downloads/php/php-5.4.14
[root@pangou php-5.4.14]# ls
acinclude.m4 CREDITS ltmain.sh NEWS README.MAILINGLIST_RULES README.TESTING stamp-h.in
aclocal.m4 ext main pear README.namespaces README.TESTING2 stub.c
build EXTENSIONS makedist php5.spec.in README.NEW-OUTPUT-API README.UNIX-BUILD-SYSTEM svnclean.bat
buildconf footer Makefile.frag php.gif README.PARAMETER_PARSING_API README.WIN32-BUILD-SYSTEM tests
buildconf.bat generated_lists Makefile.gcov php.ini-development README.PHP4-TO-PHP5-THIN-CHANGES run-tests.php TSRM
CODING_STANDARDS genfiles Makefile.global php.ini-production README.REDIST.BINS sapi UPGRADING
config.guess header makerpm README.EXTENSIONS README.RELEASE_PROCESS scripts UPGRADING.INTERNALS
config.sub INSTALL missing README.EXT_SKEL README.SELF-CONTAINED-EXTENSIONS server-tests-config.php vcsclean
configure install-sh mkinstalldirs README.GIT-RULES README.STREAMS server-tests.php win32
configure.in LICENSE netware README.input_filter README.SUBMITTING_PATCH snapshot Zend
[root@pangou php-5.4.14]# ./configure --prefix=/opt/php --with-config-file-path=/opt/php/etc --with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic
// 编译时间可能有点长。。。
// 编译成功后,安装
[root@pangou php-5.4.14]# make && make install
// 安装时间也比较长
安装成功后,php的位置就应该在/opt/php目录下,接下去就是配置
// 复制配置文件到配置目录下
[root@pangou php-5.4.14]# cp /root/Downloads/php/php-5.4.14/php.ini-production /opt/php/etc/php.ini
[root@pangou php-5.4.14]# cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf
[root@pangou php-5.4.14]# cd /opt/php/etc/
[root@pangou etc]# ls
php-fpm.conf php-fpm.conf.default php.ini
// 然后配置nginx的配置文件,让其可以运行php
[root@pangou etc]# cd /opt/nginx/conf/
[root@pangou conf]# ls
fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf
fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default
[root@pangou conf]# vim nginx.conf
1、去掉 #user nobody; 的#号, 变成 user nobody;
2、去掉
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
之前的#号,
并修改
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
为
[/cfastcgi_param SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name;
ode]
最终修改后的内容为:
[code]
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name;
include fastcgi_params;
}