主机名 | IP地址 | 角色 | 系统版本 |
---|---|---|---|
nginx-server | 192.168.100.114 | nginx服务 | red-hat7 |
msyql-server | 192.168.100.60 | mysql php服务 | red-hat7 |
[root@mysql-server ~]# systemctl stop firewalld
[root@mysql-server ~]# systemctl disable firewalld
[root@mysql-server ~]# setenforce 0
安装过程请看上篇
https://blog.csdn.net/weixin_43120459/article/details/83153510
[root@mysql-server ~]# cd /usr/src/
[root@mysql-server src]# ls
debug kernels mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
[root@mysql-server src]# tar xf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@mysql-server src]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
[root@mysql-server src]# groupadd -r -g 306 mysql
[root@mysql-server src]# useradd -r -M -s /sbin/nologin -g 306 mysql
[root@mysql-server src]# cd /usr/local/
[root@mysql-server local]# ln -s mysql-5.7.23-linux-glibc2.12-x86_64/ mysql
[root@mysql-server local]# chown -R mysql.mysql /usr/local/mysql
[root@mysql-server local]# ll
total 0
drwxr-xr-x. 2 root root 6 Mar 10 2016 bin
drwxr-xr-x. 2 root root 6 Mar 10 2016 etc
drwxr-xr-x. 2 root root 6 Mar 10 2016 games
drwxr-xr-x. 2 root root 6 Mar 10 2016 include
drwxr-xr-x. 2 root root 6 Mar 10 2016 lib
drwxr-xr-x. 2 root root 6 Mar 10 2016 lib64
drwxr-xr-x. 2 root root 6 Mar 10 2016 libexec
lrwxrwxrwx 1 root root 36 Oct 18 10:21 mysql -> mysql-5.7.23-linux-glibc2.12-x86_64/
drwxr-xr-x 9 root root 129 Oct 18 10:18 mysql-5.7.23-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root 6 Mar 10 2016 sbin
drwxr-xr-x. 5 root root 49 Aug 24 11:29 share
drwxr-xr-x. 2 root root 6 Mar 10 2016 src
[root@mysql-server local]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql
[root@mysql-server local]# . /etc/profile.d/mysql
[root@mysql-server local]# which mysql
/usr/local/mysql/bin/mysql
[root@mysql-server local]# mkdir /opt/data -p
[root@mysql-server local]# chown -R mysql.mysql /opt/data/
[root@mysql-server local]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
[root@mysql-server local]# echo "/>:IFFrFk6hr" > /root/a
[root@mysql-server local]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@mysql-server local]# ldconfig -v
[root@mysql-server local]# cat > /etc/my.cnf << EOF
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
EOF
[root@mysql-server local]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@mysql-server local]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
[root@mysql-server local]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld
[root@mysql-server local]# service mysqld start
Starting MySQL.Logging to '/opt/data/mysql-server.err'.
SUCCESS!
[root@mysql-server local]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
[root@mysql-server local]# mysqladmin -uroot -p"/>:IFFrFk6hr" password 123.com
[root@php ~]# yum -y 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-develreadline readline-devel libxslt libxslt-devel mhash mhash-deve
[root@msyql-server ~]# cd /usr/src/
[root@msyql-server ~]# wget http://cn.php.net/distributions/php-7.2.8.tar.xz
[root@msyql-server ~]# tar xf php-7.2.10.tar.xz
[root@msyql-server ~]# cd php-7.2.10/
[root@msyql-server ~]# ./configure --prefix=/usr/local/php7 \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir=/usr \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \>
--with-pear \
--with-jpeg-dir \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--with-bz2 \
--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-xml \
--enable-zip
[root@mysql-server php-7.2.10]# make && make install
[root@mysql-server php-7.2.10]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@mysql-server php-7.2.10]# source /etc/profile.d/php7.sh
[root@mysql-server php-7.2.10]# which php
/usr/local/php7/bin/php
[root@mysql-server php-7.2.10]# php -v
PHP 7.2.10 (cli) (built: Oct 18 2018 11:00:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
[root@mysql-server php-7.2.10]# cp php.ini-production /etc/php.ini
[root@mysql-server php-7.2.10]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@mysql-server php-7.2.10]# chmod +x /etc/init.d/php-fpm
[root@mysql-server php-7.2.10]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
[root@mysql-server php-7.2.10]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
[root@mysql-server php-7.2.10]# tail /usr/local/php7/etc/php-fpm.conf
; file.
; Relative path can also be used. They will be prefixed by:
; - the global prefix if it's been set (-p argument)
; - /usr/local/php7 otherwise
include=/usr/local/php7/etc/php-fpm.d/*.conf
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 8
[root@mysql-server php-7.2.10]# service php-fpm start
Starting php-fpm done
[root@mysql-server php-7.2.10]# ss -anlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
[root@nginx-server ~]# vim /usr/local/nginx/conf/nginx.conf
worker_processes 1;
error_log logs/error.log; //去掉此行的注释
#error_log logs/error.log notice;
#error_log logs/error.log info;
启用以php结尾的网站模板
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /www;
fastcgi_pass 192.168.100.60:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
//修改server下面的内容
#gzip on;
server {
listen 80;
server_name www.xiefei.com;
charset koi8-r;
access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
//启用以下几行
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"';
[root@mysql-server ]# groupadd -r nginx
[root@mysql-server ]# useradd -r -M -s /sbin/nologin -g nginx nginx
[root@mysql-server ~]# tail /usr/local/php7/etc/php-fpm.conf
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 8
listen = 192.168.100.60:9000
user = nginx
group = nginx
[root@mysql-server ]# mkdir /www
[root@mysql-server ]# chown -R nginx.nginx /www
[root@mysql-server ]# cd /www/
[root@mysql-server www]# cat test.php
*5.重启Nginx端的nginx,mysql的php
[root@nginx-server html]# service nginx restart
[root@mysql-server ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done