So kompilieren und installieren Sie Nginx und PHP: 1. Installieren Sie abhängige Pakete über den Befehl yum install. 2. Laden Sie das Quellcodepaket herunter, dekomprimieren und kompilieren Sie es. 4. Starten Sie Nginx und konfigurieren Sie es systemctl zum Starten; 5. PHP herunterladen und einfach dekomprimieren und kompilieren.
Die Betriebsumgebung dieses Tutorials: Windows 10-System, PHP 7.2.33-Version, DELL G3-Computer
Wie kompiliere und installiere ich Nginx und PHP? „nginx und php kompilieren und installieren“ Starten Sie Nginx
yum install -y gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel
Systemctl-Startup konfigurieren [root@web03 ~]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
[root@web03 ~]# tar xf nginx-1.18.0.tar.gz
[root@web03 ~]# cd nginx-1.18.0/
[root@web03 nginx-1.18.0]# ./configure --prefix=/usr/local/nginx \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_realip_module \ --with-http_stub_status_module \ --with-http_gzip_static_module \ --with-pcre \ --with-stream \ --with-stream_ssl_module \ --with-stream_realip_module [root@web03 nginx-1.18.0]# make && make install [root@web03 nginx-1.18.0]# cd /usr/local/nginx/ [root@web03 nginx]# tree . ├── conf │ ├── fastcgi.conf │ ├── fastcgi.conf.default │ ├── fastcgi_params │ ├── fastcgi_params.default │ ├── koi-utf │ ├── koi-win │ ├── mime.types │ ├── mime.types.default │ ├── nginx.conf │ ├── nginx.conf.default │ ├── scgi_params │ ├── scgi_params.default │ ├── uwsgi_params │ ├── uwsgi_params.default │ └── win-utf ├── html │ ├── 50x.html │ └── index.html ├── logs └── sbin └── nginx
php kompilieren und installieren
Abhängigkeitspaket
Quellcode-Download
[root@web03 nginx]# useradd -s /sbin/nologin -M www [root@web03 conf]# ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/ [root@web03 nginx]# mkdir conf/conf.d # 拆分默认配置和虚拟主机 user www; worker_processes auto; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; tcp_nopush on; server_tokens off; #keepalive_timeout 0; keepalive_timeout 65; gzip on; include conf.d/*.conf; } #虚拟主机配置文件 [root@web03 conf]# vim conf.d/www.conf server { listen 80; server_name localhost; charset utf-8; location / { root html; index index.html index.htm; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { proxy_pass http://127.0.0.1; } 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; proxy_set_header Referer $http_referer; proxy_set_header Cookie $http_cookie; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
kompilieren
nginx nginx -s reload 重启
Konfiguration
[root@web03 conf]# cat /usr/lib/systemd/system/nginx.service [Unit] Description=The nginx HTTP and reverse proxy server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/bin/rm -f /usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload KillSignal=SIGQUIT TimeoutStopSec=5 KillMode=process PrivateTmp=true [Install] WantedBy=multi-user.target
Systemstart
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum install php71w
Nginx testen
[root@web03 ~]# wget http://hk1.php.net/get/php-7.2.33.tar.gz [root@web03 ~]# tar xf php-7.2.33.tar.gz [root@web03 ~]# cd php-7.2.33/
MySQL testen
yum install bzip2 bzip2-devel -y yum install curl curl-devel -y yum install php-mcrypt libmcrypt libmcrypt-devel -y yum install readline-devel -y ./configure --prefix=/usr/local/php7 --enable-fpm \ --with-zlib \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-opcache \ --with-fpm-user=www \ --with-fpm-group=www \ --with-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-gettext \ --enable-mbstring \ --with-iconv \ --with-mcrypt \ --with-mhash \ --with-openssl \ --enable-bcmath \ --enable-soap \ --with-libxml-dir \ --enable-pcntl \ --enable-shmop \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-sockets \ --with-curl \ --with-zlib \ --enable-zip \ --with-bz2 \ --with-readline make && make install
Empfohlenes Lernen: „
PHP-Video-Tutorial》
Das obige ist der detaillierte Inhalt vonSo kompilieren und installieren Sie Nginx und PHP. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!