ip | 设备 |
---|---|
192.168.89.132 | NGINX |
192.168.89.129 | PHP |
192.168.89.131 | MYSQL |
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://downloads.mysql.com/archives/get/file/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
[root@localhost src]# groupadd -r -g 306 mysql
[root@localhost src]# useradd -M -s /sbin/nologin -g 306 -u 306 mysql
[root@localhost src]# tar xvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# cd /usr/local/
[root@localhost local]# ls
bin games lib libexec nginx share
etc include lib64 mysql-5.7.23-linux-glibc2.12-x86_64 sbin src
[root@localhost local]# ln -sv mysql-5.7.23-linux-glibc2.12-x86_64/ mysql 创建软连接
"mysql" -> "mysql-5.7.23-linux-glibc2.12-x86_64/"
[root@localhost local]# ll
lrwxrwxrwx 1 root root 36 10月 19 08:34 mysql -> mysql-5.7.23-linux-glibc2.12-x86_64/
drwxr-xr-x 9 root root 129 10月 19 08:33 mysql-5.7.23-linux-glibc2.12-x86_64
[root@localhost local]# chown -R mysql.mysql /usr/local/mysql
[root@localhost local]# ll
lrwxrwxrwx 1 mysql mysql 36 10月 19 08:34 mysql -> mysql-5.7.23-linux-glibc2.12-x86_64/
drwxr-xr-x 9 root root 129 10月 19 08:33 mysql-5.7.23-linux-glibc2.12-x86_64
[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost local]# . /etc/profile.d/mysql.sh
[root@localhost local]# which mysql
/usr/local/mysql/bin/mysql
[root@localhost local]# mkdir /opt/data
[root@localhost local]# chown -R mysql.mysql /opt/data/
[root@localhost local]# ll /opt/data/ -d
drwxr-xr-x 2 mysql mysql 6 10月 19 08:36 /opt/data/
[root@localhost local]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
······
2018-10-19T00:37:36.976376Z 1 [Note] A temporary password is generated for root@localhost: /gfwaEeY8FBs 最后一行为随机密码
[root@localhost local]# ln -sv /usr/local/mysql/include/ /usr/local/include/mysql
"/usr/local/include/mysql" -> "/usr/local/mysql/include/"
[root@localhost local]# ll /usr/local/include/
总用量 0
lrwxrwxrwx 1 root root 25 10月 19 08:39 mysql -> /usr/local/mysql/include/
[root@localhost local]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@localhost local]# ldconfig -v
[root@localhost local]# cat > /etc/my.cnf < [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@localhost local]# cat /etc/my.cnf
[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
[root@localhost local]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost local]# cd /usr/local/mysql/support-files/
[root@localhost support-files]# vim mysql.server
basedir=/usr/local/mysql
datadir=/opt/data 修改这两行
[root@localhost support-files]# service mysqld start
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
SUCCESS!
[root@localhost support-files]# mysql -uroot -p
Enter password:
mysql> set password = password('wscl1996.');
Query OK, 0 rows affected, 1 warning (0.00 sec)
[root@localhost ~]# groupadd -r -g 955 nginx
[root@localhost ~]# useradd -M -s /sbin/nologin -g 955 -u 955 nginx
[root@localhost ~]# id nginx
uid=955(nginx) gid=955(nginx) 组=955(nginx) 确保php和nginx的nginx用户的uid,gid,组id一致
[root@localhost ~]# yum -y install epel-release gcc gcc-c++
[root@localhost ~]# 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-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget http://cn.php.net/distributions/php-7.2.8.tar.xz
[root@localhost src]# tar xvf php-7.2.8.tar.xz
[root@localhost src]# cd php-7.2.8/
[root@localhost php-7.2.8]# ./configure --prefix=/usr/local/php7 --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt=/usr/local/libmcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts && make && make install
[root@localhost php-7.2.8]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@localhost php-7.2.8]# source /etc/profile.d/php7.sh
[root@localhost php-7.2.8]# which php
/usr/local/php7/bin/php
[root@localhost php-7.2.8]# cp php.ini-production /etc/php.ini
[root@localhost php-7.2.8]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.2.8]# chmod +x /etc/rc.d/init.d/php-fpm
[root@localhost php-7.2.8]# cd /usr/local/php7/etc/
[root@localhost etc]# ll
总用量 12
-rw-r--r-- 1 root root 1244 10月 19 09:16 pear.conf
-rw-r--r-- 1 root root 4468 10月 19 09:16 php-fpm.conf.default
drwxr-xr-x 2 root root 30 10月 19 09:16 php-fpm.d
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# cd php-fpm.d/
[root@localhost php-fpm.d]# cp www.conf.default www.conf
[root@localhost php-fpm.d]# cd ..
[root@localhost etc]# vim php-fpm.conf
user = nginx
group = nginx
listen = 192.168.89.129:9000 本机ip
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 8
[root@localhost etc]# service php-fpm start
Starting php-fpm done
[root@localhost etc]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 80 :::3306 :::*
LISTEN 0 128 :::80 :::*
[root@localhost ~]# groupadd -r -g 955 nginx
[root@localhost ~]# useradd -M -s /sbin/nologin -g 955 -u 955 nginx
[root@localhost ~]# id nginx
uid=955(nginx) gid=955(nginx) 组=955(nginx)
[root@localhost ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++
[root@localhost ~]# yum -y groups mark install 'Development Tools'
[root@localhost ~]# mkdir -p /var/log/nginx
[root@localhost ~]# chown -R nginx.nginx /var/log/nginx/
[root@localhost ~]# ll /var/log/nginx/ -d
drwxr-xr-x 2 nginx nginx 6 10月 18 10:39 /var/log/nginx/
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
[root@localhost src]# tar -xvf nginx-1.12.0.tar.gz
[root@localhost src]# cd nginx-1.12.0/
[root@localhost nginx-1.12.0]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-debug \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log
[root@localhost nginx-1.12.0]# make && make install
[root@localhost nginx-1.12.0]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@localhost nginx-1.12.0]# . /etc/profile.d/nginx.sh
[root@localhost nginx-1.12.0]# which nginx
/usr/local/nginx/sbin/nginx
[root@localhost nginx-1.12.0]# nginx 启动nginx
[root@localhost nginx-1.12.0]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:80 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
-t 检查配置文件语法
-v 输出nginx版本
-c 制定配置文件路径
-s 发送服务控制信号ํ{stop|quit|reopen|reload}
[root@localhost ~]# cd /usr/local/nginx/conf/
[root@localhost conf]# vim nginx.conf
#access_log logs/host.access.log main;
location / {
root html;
index index.php index.html index.htm; 在后面加上index.php
······
location ~ \.php$ {
root html;
fastcgi_pass 192.168.89.129:9000; php的ip地址
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; 去掉这几行前面的#号
[root@localhost ~]# mkdir -R /usr/local/nginx/html/
[root@localhost ~]# chown -R nginx.nginx /usr/local/nginx/html/
[root@localhost ~]# cd /usr/local/nginx/html/
[root@localhost ~]# vim index.php
[root@localhost ~]# cd /usr/local/nginx/html
[root@localhost ~]# vim index.php
[root@localhost ~]# nginx -s reload
[root@localhost ~]# service php-fpm restart
[root@localhost ~]# mysql -uroot -p
mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on wordpress.* to root@'%' identified by 'cl996.';
Query OK, 0 rows affected, 1 warning (0.00 sec)
[root@localhost ~]# wget https://wordpress.org/latest.tar.gz
[root@localhost ~]# tar zxf latest.tar.gz
[root@localhost ~]# mv wordpress/* /usr/local/nginx/html/
[root@localhost ~]# wget https://wordpress.org/latest.tar.gz
[root@localhost ~]# tar zxf latest.tar.gz
[root@localhost ~]# mv wordpress/* /usr/local/nginx/html/