1.安装环境软件包
yum -y install pcre-devel zlib-devel gcc gcc-c++
useradd -M -s /sbin/nologin nginx
tar zxvf nginx-1.12.0.tar.gz -C /opt/
//nginx-1.12.0.tar.gz 下载链接:https://pan.baidu.com/s/15sPo0VJ88C4Wxl8SRvU34w 密码:jxp1
手工编译安装nginx
cd nginx-1.12.0/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ //创建软链接便于管理
-----检查、启动、重启、停止--------
nginx -t //检查
nginx //启动
killall -1 nginx //重启
killall -3 nginx //停止
-------制作管理角本--------
vi /etc/init.d/nginx
#!/bin/bash
chkconfig: - 99 20
description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
start)
$PROG
;;
stop)
kill -s QUIT $(cat $PIDF)
;;
restart)
$0 stop
$0 start
;;
reload)
kill -s HUP $(cat $PIDF)
;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
chmod +x /etc/init.d/nginx
chkconfig --add nginx
chkconfig --level 35 nginx on
systemctl start nginx
systemctl status nginx
------------配置LNMP------------------------------------------------
yum -y install ncurses-devel cmake //ncurses是字符终端下屏幕控制的基本库//
tar xzvf mysql-5.5.24.tar.gz -C /opt //链接:https://pan.baidu.com/s/1hcrt8wbomTaVOpP3zk6SAA 密码:88e6
cd /opt/mysql-5.5.24
rpm -ivh /mnt/Packages/cmake-2.6.4-5.el6.x86_64.rpm
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/home/mysql/ \
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_SSL=system \
-DMYSQL_TCP_PORT=3306 \
-DENABLE_DOWNLOADS=1 \
-DWITH_SSL=bundled
make && make install
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
echo "PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile
source /etc/profile
useradd -s /sbin/nologin mysql
chown -R mysql.mysql /usr/local/mysql
/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql
ln -s /var/lib/mysql/mysql.sock /home/mysql/mysql.sock
vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/home/mysql
--------重新安装PHP-----------
首先安装GD库及GD库关联程序
yum -y install \
gd \
libxml2-devel \
libjpeg-devel \
libpng-devel \
zlib-devel \
fontconfig-devel \
openssl-devel \
bzip2-devel
tar zxvf php-5.3.28.tar.gz -C /opt
----------PHP5.3.28源码目录下------------
./configure \
--prefix=/usr/local/php5 \
--with-gd \
--with-zlib \
--with-mysql=/usr/local/mysql \
--with-config-file-path=/usr/local/php5 \
--enable-mbstring \
--with-jpeg-dir \
--with-openssl \
--disable-ipv6 \
--enable-fpm
make && make install
cp /opt/php-5.3.28/php.ini-development /usr/local/php5/php.ini
ln -s /usr/local/php5/bin/ /usr/local/bin/
ln -s /usr/local/php5/sbin/ /usr/local/sbin/
-------为PHP安装加速器---------
tar xzvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz -C /opt
cd /opt/ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x
cp ZendGuardLoader.so /usr/local/php5/lib/php
-------配置PHP识别加速器-----
vim /usr/local/php5/php.ini
在末尾插入如下内容
[Zend Guard Loader]
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
---------开启nginx的PHP支持--------
cd /usr/local/php5/etc/
cp php-fpm.conf.default php-fpm.conf
useradd -M -s /sbin/nologin php
vim php-fpm.conf //修改,不是刷
pid = run/php-fpm.pid
user = php
group = php
pm.max_children=50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
/usr/local/sbin/php-fpm
netstat -tnal | grep 9000
--------以下是让nginx支持PHP功能--------
vi /usr/local/nginx/conf/nginx.conf
location ~ .php$ {
root /var/www/benet;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
cd /var/
mkdir www
mkdir benet
vim /var/www/benet/index.php
phpinfo();
?>