centos7.9编译安装nginx-1.22.0,php-7.4.30,php-8.0.23
2022年9月16日13:26:15
yum -y install gcc gcc-c++ autoconf nss_ldap libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers pcre pcre-devel make wget vim cmake gd gd-devel libevent libevent-devel zip unzip libtool
yum -y install make apr* autoconf automake curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel gd gettext gettext-devel keyutils patch perl mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch
groupadd www
useradd -r -g www www -s /sbin/nologin
yum install gdbm-devel
cp -frp /usr/lib64/libldap* /usr/lib/
安装nginx
./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--error-log-path=/usr/local/nginx/error.log \
--http-log-path=/usr/local/nginx/access.log \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-pcre \
--with-http_realip_module \
--with-http_sub_module \
--with-http_v2_module
make && make install
添加启动脚本
vi /etc/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重写脚本,需要重启daemon-reload
systemctl daemon-reload
虚拟机
server {
listen 80;
server_name 127.0.0.1;
root "/data/wwwroot/127";
index index.php index.html;
charset utf-8;
location / {
autoindex off;
}
location ~ \.php(.*)$ {
fastcgi_pass unix:/usr/local/php74/php-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
安装php7.4
./configure --prefix=/usr/local/php74 \
--with-config-file-path=/usr/local/php74/etc \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--with-ldap=shared \
--with-gdbm \
--with-pear \
--with-gettext \
--with-curl \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--with-gd \
--enable-fpm \
--enable-mysqlnd \
--enable-mysqlnd-compression-support \
--enable-xml \
--enable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-ftp \
--enable-gd-jis-conv \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap \
--enable-fileinfo \
--enable-opcache \
--enable-maintainer-zts
configure: WARNING: unrecognized options: --with-freetype-dir, --with-jpeg-dir, --with-png-dir, --with-libxml-dir, --with-gd, --enable-zip
nginx包的路径
cp php.ini-production /usr/local/php74/etc/php.ini
pwd /usr/local/php74/etc
cp php-fpm.conf.default php-fpm.conf
pwd /usr/local/php74/etc/php-fpm.d
cp www.conf.default www.conf
php-fpm.conf
pid = /usr/local/php74/php-fpm.pid
www.conf 二选一
listen = 127.0.0.1:9000
listen = /usr/local/php74/php-fpm.sock
error_log = /data/log/php74/php-fpm.log
slowlog = /data/log/php74/slow.log
vi /etc/systemd/system/php74-fpm.service
[Unit]
Description=php74-fpm
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/usr/local/php74/php-fpm.pid
ExecStart=/usr/local/php74/sbin/php-fpm -c /usr/local/php74/etc/php.ini -y /usr/local/php74/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
安装php8.0
./configure --prefix=/usr/local/php80 \
--with-config-file-path=/usr/local/php80/etc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-mysqlnd-compression-support \
--with-iconv-dir \
--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-libmbfl \
--enable-ftp \
--with-gd \
--enable-gd-jis-conv \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-gettext \
--enable-fileinfo \
--enable-opcache \
--with-pear \
--enable-maintainer-zts \
--with-ldap=shared \
--without-gdbm
configure: WARNING: unrecognized options: --with-iconv-dir, --with-freetype-dir, --with-jpeg-dir, --with-png-dir, --with-libxml-dir, --enable-inline-optimization, --with-libmbfl, --with-gd, --with-xmlrpc, --enable-zip, --enable-maintainer-zts
vi /etc/systemd/system/php80-fpm.service
systemctl daemon-reload
[Unit]
Description=php80-fpm
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/usr/local/php80/php-fpm.pid
ExecStart=/usr/local/php80/sbin/php-fpm -c /usr/local/php80/etc/php.ini -y /usr/local/php80/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
其他和7.4是一样的
nginx包的路径
cp php.ini-production /usr/local/php80/etc/php.ini
pwd /usr/local/php80/etc
cp php-fpm.conf.default php-fpm.conf
pwd /usr/local/php80/etc/php-fpm.d
cp www.conf.default www.conf
php-fpm.conf
pid = /usr/local/php80/php-fpm.pid
www.conf 二选一
listen = 127.0.0.1:9000
listen = /usr/local/php80/php-fpm.sock
error_log = /data/log/php80/php-fpm.log
slowlog = /data/log/php80/slow.log
QQ一群 247823727
QQ二群 166427999
博客文件如果不能下载请进群下载
如果公司项目有技术瓶颈问题,请联系↓↓
如果需要定制系统开发服务,请联系↓↓
技术服务QQ: 903464207
QQ二群 166427999
博客文件如果不能下载请进群下载
如果公司项目有技术瓶颈问题,请联系↓↓
如果需要定制系统开发服务,请联系↓↓
技术服务QQ: 903464207