centos7 nginx php7.2.5 环境安装

下载php

wget http://cn2.php.net/get/php-7.2.5.tar.gz/from/this/mirror

 

解压

mv mirror.1 php7.2.5.tar.gz

tar -vxzf php7.2.5.tar.gz

 

安装依赖
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel

 

安装gcc

yum -y install gcc

 

编译安装

./configure –prefix=/usr/local/php –with-config-file-path=/etc –enable-fpm –with-fpm-user=nginx –with-fpm-group=nginx –enable-inline-optimization –disable-debug –disable-rpath –enable-shared –enable-soap –with-libxml-dir –with-xmlrpc –with-openssl –with-mcrypt –with-mhash –with-pcre-regex –with-sqlite3 –with-zlib –enable-bcmath –with-iconv –with-bz2 –enable-calendar –with-curl –with-cdb –enable-dom –enable-exif –enable-fileinfo –enable-filter –with-pcre-dir –enable-ftp –with-gd –with-openssl-dir –with-jpeg-dir –with-png-dir –with-zlib-dir –with-freetype-dir –enable-gd-native-ttf –enable-gd-jis-conv –with-gettext –with-gmp –with-mhash –enable-json –enable-mbstring –enable-mbregex –enable-mbregex-backtrack –with-libmbfl –with-onig –enable-pdo –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-zlib-dir –with-pdo-sqlite –with-readline –enable-session –enable-shmop –enable-simplexml –enable-sockets –enable-sysvmsg –enable-sysvsem –enable-sysvshm –enable-wddx –with-libxml-dir –with-xsl –enable-zip –enable-mysqlnd-compression-support –with-pear –enable-opcache

make && make install

配置环境变量

vi /etc/profile

在末尾添加

PATH=$PATH:/usr/local/php/bin

export PATH

 

执行命令环境变量生效

source /etc/profile

 

 

配置php

cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
创建用户
groupadd nginx
useradd -g nginx nginx

.启动php-fpm

/etc/init.d/php-fpmstart
设置开机启动
vi /etc/init.d/php-fpm
安装nginx
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
网上是这么写的
./configure \
–prefix=/usr/local/nginx \
–sbin-path=/usr/local/nginx/sbin/nginx \
–conf-path=/usr/local/nginx/nginx.conf \
–pid-path=/usr/local/nginx/nginx.pid \
–user=nginx \
–group=nginx \
–with-http_ssl_module \
–with-http_flv_module \
–with-http_mp4_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=/usr/local/src/pcre-8.39 \
–with-zlib=/usr/local/src/zlib-1.2.8 \
–with-openssl=/usr/local/src/openssl-1.1.0b \
我换成了
./configure –prefix=/usr/local/nginx –sbin-path=/usr/local/nginx/sbin/nginx –conf-path=/usr/local/nginx/nginx.conf –pid-path=/usr/local/nginx/nginx.pid –user=nginx –group=nginx –with-http_ssl_module –with-http_flv_module –with-http_mp4_module –with-http_stub_status_module –with-http_gzip_static_module
安装
make && make install
开机启动
vi /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true[Install]
WantedBy=multi-user.target
systemctl enable nginx.service
 这时候应该已经安装完成了
可以 ps -aux 查看
#docker相关请忽略
#执行某个镜像
#docker run -itd -P my/centos /usr/sbin/init
#push到腾讯云
#docker push ccr.ccs.tencentyun.com/kkshsh/php7_nginx:v1.0.1
#提交前设置tag
#docker tag my/centos:v1.1.1 ccr.ccs.tencentyun.com/kkshsh/php7_nginx:v1.0.1
#保存本地镜像
#docker commit 4258a28f6e71 my/centos:v1.1.1
#查看正在运行的容器
#docker ps
#进入正在运行的容器
#docker exec -it infallible_goldstine /bin/bash
#安装ssh 一般都有不需要安装  用在docker
yum install openssh-server -y
systemctl enable sshd
systemctl start sshd

LEAVE A COMMENT