lnmp environment, php and nginx are installed on a machine, mysql is a separate server.
Install php7.3
download
wget https://downloads.php.net/~cmb/php-7.3.0beta1.tar.gz
tar -zxvf php-7.3.0beta1.tar.gz
useradd -s /sbin/nologin php-fpm
Compile
./configure –prefix=/usr/local/php –with-curl –with-freetype-dir
–with-gd –with-gettext –with-iconv-dir –with-kerberos –with-libdir=lib64 –with-libxml-dir –with-mysqli –with-openssl –with-pcre-regex –with-pdo-mysql –with-pdo-sqlite –with-pear –with-png-dir –with-jpeg-dir –with-xmlrpc –with-xsl –with-zlib –with-bz2 –with-mhash –enable-fpm –enable-bcmath –enable-libxml –enable-inline-optimization –enable-mbregex –enable-mbstring –enable-opcache –enable-pcntl –enable-shmop –enable-soap –enable-sockets –enable-sysvsem –enable-sysvshm –enable-xml –enable-zip –enable-fpm –with-fpm-user=php-fpm –with-fpm-group=php-fpm
Error reporting: 1,
**configure: error: system libzip must be upgraded to version >=**0.11. The latest version of Yum is only 0.10, which is not enough to meet the requirements. First, delete libzip yum remove libzip -y SSH executes the above commands by deleting libzip and libzip-devel 2. Download, install and compile manually wget https://nih.at/libzip/libzip-1.2.0.tar.gz tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure make && make install 3. (Neglectable) For the latest edition, please refer to the official website: https://nih.at/libzip/1.5.0 libzip requires cmake. wget https://libzip.org/download/libzip-1.5.0.tar.gz tar -zxvf libzip-* cd libzip* mkdir build && cd build && cmake .. && make && make install
Wrong 2:
error: off_t undefined; check your library configuration Analyse configure: error: off_t undefined; check your library configuration based on error information The undefined type off_t. The off_t type is defined in the header file unistd.h. The 32-bit system is programmed into long int, while the 64-bit system is compiled into long long int. The title system should be 64-bit. When compiling, the 64-bit dynamic link library is searched by default, but the search path is not added in the dynamic link library configuration file/etc/ld.so.conf of centos by default. At this point, you need to add / usr/local/lib64 /usr/lib64 library file paths for 64 bits. Use the following method. Add search path to configuration file ``` echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>/etc/ld.so.conf Then update the configuration ldconfig -v
Successful compilation again
Execute installation:
make && make install
Report errors:
/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory
Solve:
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
Successful installation:
Copy the configuration file:
cp php.ini-production /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
ln -s /usr/local/php/sbin/php-fpm /usr/local/bin
Modify configuration:
cd /usr/local/php/etc/php-fpm.d
vim www.conf
[www] //pool Subname Settings
;listen = /tmp/php-fcgi.sock // The address to listen on, either socket or port
listen = 127.0.0.1:8089 Or write it like this. php-fpm Usually used locally. php and nginx Usually in a machine, so it can be written127.0.0.1,Other machines need to be connected by this machine. ip
listen.mode = 666 //The permissions of sock files
listen.owner = nobody
listen.group = nobody
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
Join the system TL service:
cd /usr/local/src/php-7.3.0beta1/sapi/fpm
cp php-fpm.service /usr/lib/systemd/system/
Start up:
[root@linshi fpm]# systemctl start php-fpm
[root@linshi fpm]# systemctl status php-fpm -l
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2018-08-09 12:42:35 CST; 2s ago
Main PID: 7441 (php-fpm)
Memory: 47.6M
CGroup: /system.slice/php-fpm.service
├─7441 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
├─7442 php-fpm: pool www
├─7443 php-fpm: pool www
├─7444 php-fpm: pool www
├─7445 php-fpm: pool www
├─7446 php-fpm: pool www
├─7447 php-fpm: pool www
├─7448 php-fpm: pool www
├─7450 php-fpm: pool www
├─7451 php-fpm: pool www
├─7452 php-fpm: pool www
├─7453 php-fpm: pool www
├─7454 php-fpm: pool www
├─7456 php-fpm: pool www
├─7457 php-fpm: pool www
├─7458 php-fpm: pool www
├─7459 php-fpm: pool www
├─7460 php-fpm: pool www
├─7461 php-fpm: pool www
├─7462 php-fpm: pool www
└─7464 php-fpm: pool www
Aug 09 12:42:35 linshi systemd[1]: Started The PHP FastCGI Process Manager.
Aug 09 12:42:35 linshi systemd[1]: Starting The PHP FastCGI Process Manager...
Install nginx 1.4
Download:
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.14.0.tar.gz
//Download Clean Cache Plug-in at the same time
wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
tar -zxvf ngx_cache_purge-2.3.tar.gz
tar -zxvf nginx-1.14.0.tar.gz
Compilation and installation
cd nginx-1.14.0
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --add-module=/usr/local/src/ngx_cache_purge-2.3
make && make install
Make soft connection:
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
Add system CTL
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
Modify the configuration file:
cd /usr/local/nginx/conf
vim nginx.conf
Delete the server section
Finally, add a sentence:
include vhost/*.conf;
Example:
#user nobody;
worker_processes 2;
#error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
#pid logs/nginx.pid;
worker_rlimit_nofile 51200;
events {
use epoll;
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;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
gzip_comp_level 5;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm application/xml;
include vhost/*.conf;
}
Join the virtual host:
cd /usr/local/nginx/conf
mkdir vhost
cd vhost
vim php.conf
//Write in:
server
{
listen 8080;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html;
## Combining with php
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass 127.0.0.1:8089;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}
Start up:
systemctl start nginx
Access testing:
Create php file tests:
cd /usr/local/nginx/html/
vim 1.php
//Write in:
<?php
phpinfo();
?>
Check that the configuration file is correct nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful Reload nginx -s reload
Access testing:
Install wordpress
Download:
wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
tar -zxvf wordpress-4.9.4-zh_CN.tar.gz
mv wordpress /usr/local/nginx/html
nginx -s reload
Access Installation:
http://47.93.6.102:8080/wordpress
Creating wordpress database on mysql server
> create database wordpress default charset 'utf8';
Query OK, 1 row affected (0.00 sec)
> grant all on wordpress.* to 'wordpress'@'%' identified by 'wordpress123';
Query OK, 0 rows affected (0.06 sec)
Fill in the database information:
Next step:
Create a file in the wordpress directory as prompted.
Next step:
Success: