一、准备工作:
@H_502_2@
软件默认下载在/usr/local/src下,安装在/app/local下的PHP、MysqL、Nginx、data目录下,安装顺序按照Nginx->MysqL->PHP进行
@H_502_2@
编译工具集:@H_502_2@
yum install -y wget gccgcc-c++autoconfautomake cmakebison m4libxml2libxml2-devellibcurl-devel libjpeg-devel libpng-devel libicu-develpcre pcre-devellibtool@H_502_2@
openssl openssl-develbzip2 bzip2-devel ncurses ncurses-develfreetype freetype-devel@H_502_2@
libxslt-devel@H_502_2@
更新系统:yum install -y update@H_502_2@
下载需要的软件:@H_502_2@
PHP:wget -c http://mirrors.sohu.com/php/php-7.0.10.tar.gz @H_502_2@
MysqL:wget -c http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-boost-5.7.14.tar.gz @H_502_2@
Nginx:wget -c http://nginx.org/download/nginx-1.10.1.tar.gz @H_502_2@
cmake:wget -c https://cmake.org/files/v3.1/cmake-3.1.3.tar.gz @H_502_2@
PHP需要的一些库文件:wget -chttp://zlib.net/zlib-1.2.8.tar.gz @H_502_2@
wget -c http://blog.zyan.cc/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz@H_502_2@
wget -c http://blog.zyan.cc/soft/linux/Nginx_PHP/mcrypt/mcrypt-2.6.8.tar.gz@H_502_2@
wget -c http://blog.zyan.cc/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz @H_502_2@
新建用户和组:useradd -u 500 -g 500 -G 500 -s /sbin/nologin www@H_502_2@
groupadd -g 500 www@H_502_2@
新建相应的目录:mkdir -p /app/local/{Nginx,MysqL,PHP,data}@H_502_2@
#tar zxvfNginx-1.10.1.tar.gz@H_502_2@
#可以通过./configure --help查看帮助
@H_502_2@
#./configure --prefix=/app/local/Nginx --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module@H_502_2@
#make && make install@H_502_2@
#cd ../
@H_502_2@
#systemctl stop firewalld.service#关闭防火墙@H_502_2@
#/app/local/Nginx/sbin/Nginx #开启Nginx
@H_502_2@
#可以通过curl判断Nginx是否正常访问或者在浏览器地址栏输入ip地址查看
@H_502_2@
#tar zxvf cmake-3.1.3.tar.gz@H_502_2@
#cd cmake-3.1.3@H_502_2@
#./configure@H_502_2@
#make && make install@H_502_2@
#cd ../@H_502_2@
#tar zxvf MysqL-boost-5.7.14.tar.gz@H_502_2@
#cmake -DCMAKE_INSTALL_PREFIX=/app/local/MysqL -DMysqL_UNIX_ADDR=/app/local/MysqL/MysqL.sock -DSYSCONFDIR=/app/local/MysqL/etc -DSYSTEMD_PID_DIR=/app/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 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMysqL_DATADIR=/app/local/data -DWITH_BOOST=boost -DWITH_SYSTEMD=1@H_502_2@
#make && make install@H_502_2@
#cd ../@H_502_2@
#chown -R MysqL:MysqL /app/local/MysqL/@H_502_2@
#chown -R MysqL:MysqL /app/local/data/@H_502_2@
#cd /app/local/MysqL/bin@H_502_2@
#./MysqLd --initialize --user=MysqL --basedir=/app/local/MysqL/ --datadir=/app/local/data/ #初始化数据库并且随机生成一个密码@H_502_2@
#./MysqLd --user=MysqL#开启MysqL@H_502_2@
#echo 'export PATH=$PATH:/app/local/MysqL/bin' >> /etc/profile.d/MysqL.sh@H_502_2@
#source /etc/profile.d/MysqL.sh@H_502_2@
Enter password:#输入刚才随机生成的密码@H_502_2@
MysqL>ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';#通过这个重置密码@H_502_2@
#cd /usr/local/src/
@H_502_2@
#tar zxvf mhash-0.9.9.9.tar.gz@H_502_2@
#cd mhash-0.9.9.9@H_502_2@
#./configure@H_502_2@
#make && make install@H_502_2@
#cd ../
@H_502_2@
#tar zxvf libmcrypt-2.5.8.tar.gz@H_502_2@
#cd libmcrypt-2.5.8@H_502_2@
#./configure@H_502_2@
#make && make install@H_502_2@
#cd ../
@H_502_2@
#tar zxvf mcrypt-2.6.8.tar.gz@H_502_2@
#cd mcrypt-2.6.8@H_502_2@
#./configure@H_502_2@
出现错误:configure: error: *** libmcrypt was not found@H_502_2@
解决办法:ln -s /usr/local/bin/libmcrypt_config /usr/bin/libmcrypt_config再./configure依然报错,执行export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH@H_502_2@
再./configure通过@H_502_2@
#make && make install@H_502_2@
#cd ../
@H_502_2@
#tar zxvf zlib-1.2.8.tar.gz@H_502_2@
#cd zlib-1.2.8@H_502_2@
#./configure@H_502_2@
#make && make install@H_502_2@
#cd ../
@H_502_2@
#tar zxvf PHP-7.0.10.tar.gz@H_502_2@
#./configure --prefix=/app/local/PHP --with-config-file-path=/app/local/PHP/etc --with-pdo-sqlite --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-xmlreader --enable-xmlwriter --enable-soap --enable-calendar --with-curl --with-mcrypt --with-gd --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-MysqL --with-MysqLi --with-MysqL-sock --enable-MysqLnd --with-jpeg-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-openssl --enable-ftp --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --disable-fileinfo@H_502_2@
#make && make install@H_502_2@
#cd ../
@H_502_2@
五、配置@H_502_2@
#cp /usr/local/src/PHP-7.0.10 /app/local/PHP/etc/PHP.ini@H_502_2@
#cp/app/local/PHP/etc/PHP-fpm.conf.default/app/local/PHP/etc/PHP-fpm.conf@H_502_2@
#cp/app/local/PHP/etc/PHP-fpm.d/www.conf.default/app/local/PHP/etc/PHP-fpm.d/www.conf @H_502_2@
#vi www.conf#查找/static将pm=dynamic 改成pm =static保存退出@H_502_2@
#vi/app/local/PHP/etc/PHP.ini#查找date.timezone将前面的分号去掉并设置为PRC保存退出@H_502_2@
#vi /app/local/Nginx/conf/Nginx.conf
@H_502_2@
user www www;@H_502_2@
worker_processes 4;@H_502_2@
@H_502_2@
error_log logs/error.log;@H_502_2@
#error_log logs/error.log notice;@H_502_2@
#error_log logs/error.log info;@H_502_2@
@H_502_2@
@H_502_2@
@H_502_2@
events {@H_502_2@
use epoll;@H_502_2@
worker_connections 51024;@H_502_2@
}@H_502_2@
root html;@H_502_2@
fastcgi_pass 127.0.0.1:9000;@H_502_2@
fastcgi_index index.PHP;@H_502_2@
#fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;@H_502_2@
include fastcgi.conf;@H_502_2@
}@H_502_2@
#/app/local/Nginx/sbin/Nginx -t#测试配置文件是否有误 如果出现如下则表示无误 否则会提示错误信息在多少行
@H_502_2@
Nginx: the configuration file /app/local/Nginx/conf/Nginx.conf Syntax is ok@H_502_2@
Nginx: configuration file /app/local/Nginx/conf/Nginx.conf test is successful@H_502_2@
#vi /app/local/Nginx/html/index.PHP
@H_502_2@
输入<?PHP PHPinfo ?>保存退出
@H_502_2@
#/app/local/Nginx/sbin/Nginx#启动Nginx@H_502_2@
#/app/local/PHP/sbin/PHP-fpm#启动PHP-fpm@H_502_2@
#systemctl stop firewalld.service#关闭防火墙@H_502_2@
在浏览器地址栏输入ip/index.PHP 如果出现如下则表明安装配置成功
@H_502_2@