您好,登錄后才能下訂單哦!
下載Nginx源碼包 Nginx源碼包下載
[root@localhost ~]# mount.cifs //192.168.100.10/lnmp /mnt/ //掛載目錄
Password for root@//192.168.100.10/lnmp:
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
Discuz_X3.4_SC_UTF8.zip mysql-boost-5.7.20.tar.gz nginx-1.12.2.tar.gz php-7.1.20.tar.gz
[root@localhost mnt]# yum install gcc gcc-c++ make pcre-devel zlib-devel -y //安裝環境包
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.sjtu.edu.cn
...//省略部分內容...
已安裝:
gcc.x86_64 0:4.8.5-39.el7 gcc-c++.x86_64 0:4.8.5-39.el7 pcre-devel.x86_64 0:8.32-17.el7
zlib-devel.x86_64 0:1.2.7-18.el7
作為依賴被安裝:
cpp.x86_64 0:4.8.5-39.el7 glibc-devel.x86_64 0:2.17-292.el7
glibc-headers.x86_64 0:2.17-292.el7 kernel-headers.x86_64 0:3.10.0-1062.4.1.el7
libmpc.x86_64 0:1.0.1-3.el7 libstdc++-devel.x86_64 0:4.8.5-39.el7
更新完畢:
make.x86_64 1:3.82-24.el7
作為依賴被升級:
glibc.x86_64 0:2.17-292.el7 glibc-common.x86_64 0:2.17-292.el7 libgcc.x86_64 0:4.8.5-39.el7
libgomp.x86_64 0:4.8.5-39.el7 libstdc++.x86_64 0:4.8.5-39.el7 zlib.x86_64 0:1.2.7-18.el7
完畢!
[root@localhost mnt]# tar zvxf nginx-1.12.2.tar.gz -C /opt/ //解壓環境包
[root@localhost mnt]# cd /opt/
[root@localhost opt]# ls
nginx-1.12.2 rh
[root@localhost opt]# cd nginx-1.12.2/
[root@localhost nginx-1.12.2]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@localhost nginx-1.12.2]# useradd -M -s /sbin/nologin nginx //創建Nginx程序用戶,不可登錄系統,不創建家目錄
[root@localhost nginx-1.12.2]# ./configure \ //配置nginx
> --prefix=/usr/local/nginx \ //指定安裝目錄
> --user=nginx \ //指定用戶
> --group=nginx \ //指定組
> --with-http_stub_status_module //關聯統計模塊
...//省略部分內容...
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@localhost nginx-1.12.2]# make && make install //制作安裝nginx
...//省略部分內容...
test -d '/usr/local/nginx/html' \
|| cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
|| mkdir -p '/usr/local/nginx/logs'
make[1]: 離開目錄“/opt/nginx-1.12.2”
[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/ //將命令放入系統命令下
[root@localhost nginx-1.12.2]# cd /lib/systemd/system //進入system管理目錄
[root@localhost system]# vim nginx.service //創建nginx程序管理腳本
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/bin/kill -s HUP $MAINPID
ExecStop=/usr/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
:wq
[root@localhost system]# chmod 754 nginx.service //添加執行權限
[root@localhost system]# systemctl start nginx.service //啟動服務
[root@localhost system]# netstat -ntap | grep 80 //查看端口是否開啟
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4593/nginx: master
[root@localhost system]# systemctl stop firewalld.service //關閉防火墻
[root@localhost system]# setenforce 0 //關閉增強性安全功能
[root@localhost system]# yum install ncurses ncurses-devel bison cmake -y
//安裝環境包 ncurses ncurses-devel 字符終端處理工具 bison 語法分析器
...//省略部分內容...
已安裝:
bison.x86_64 0:3.0.4-2.el7 cmake.x86_64 0:2.8.12.2-2.el7 ncurses-devel.x86_64 0:5.9-14.20130511.el7_4
作為依賴被安裝:
m4.x86_64 0:1.4.16-10.el7
更新完畢:
ncurses.x86_64 0:5.9-14.20130511.el7_4
作為依賴被升級:
ncurses-base.noarch 0:5.9-14.20130511.el7_4 ncurses-libs.x86_64 0:5.9-14.20130511.el7_4
完畢!
[root@localhost system]# useradd -s /sbin/nologin mysql //創建mysql程序目錄
[root@localhost system]# cd /mnt/
[root@localhost mnt]# ls
Discuz_X3.4_SC_UTF8.zip mysql-boost-5.7.20.tar.gz nginx-1.12.2.tar.gz php-7.1.20.tar.gz
[root@localhost mnt]# tar zxvf mysql-boost-5.7.20.tar.gz -C /opt/ //解壓源碼包
...//省略部分內容...
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_set.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_set_fwd.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_map_fwd.hpp
mysql-5.7.20/boost/boost_1_59_0/boost/timer.hpp
[root@localhost mnt]# cd /opt
[root@localhost opt]# ls
mysql-5.7.20 nginx-1.12.2 rh
[root@localhost opt]# cd mysql-5.7.20/
[root@localhost mysql-5.7.20]# cmake \ //使用cmake配置mysql
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ //指定安裝路徑
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ //指定鏈接性文件路徑
-DSYSCONFDIR=/etc \ //指定配置文件存放位置
-DSYSTEMD_PID_DIR=/usr/local/mysql \ //指定PID文件存放位置
-DDEFAULT_CHARSET=utf8 \ //指定字符集utf-8
-DDEFAULT_COLLATION=utf8_general_ci \ //指定字符集utf-8
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ //開啟存儲引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \ //指定數據存放位置
-DWITH_BOOST=boost \ //關聯支持c++運行庫
-DWITH_SYSTEMD=1 //開啟systemd(主從復制使使用)
[root@localhost mysql-5.7.20]# make //制作MySQL
[root@localhost mysql-5.7.20]# make install //安裝MySQL
[root@localhost mysql-5.7.20]# cd /usr/local/ //進入MySQL安裝目錄
[root@localhost local]# ls -l //長格式常看
總用量 0
drwxr-xr-x. 2 root root 6 11月 5 2016 bin
drwxr-xr-x. 2 root root 6 11月 5 2016 etc
drwxr-xr-x. 2 root root 6 11月 5 2016 games
drwxr-xr-x. 2 root root 6 11月 5 2016 include
drwxr-xr-x. 2 root root 6 11月 5 2016 lib
drwxr-xr-x. 2 root root 6 11月 5 2016 lib64
drwxr-xr-x. 2 root root 6 11月 5 2016 libexec
drwxr-xr-x. 11 root root 197 11月 11 21:42 mysql
drwxr-xr-x. 11 root root 151 11月 11 20:49 nginx
drwxr-xr-x. 2 root root 19 11月 11 20:49 sbin
drwxr-xr-x. 5 root root 49 8月 10 03:42 share
drwxr-xr-x. 2 root root 6 11月 5 2016 src
[root@localhost local]# chown -R mysql.mysql mysql/ //更改mysql目錄屬主、屬組為mysql程序用戶
[root@localhost local]# ls -l
總用量 0
drwxr-xr-x. 2 root root 6 11月 5 2016 bin
drwxr-xr-x. 2 root root 6 11月 5 2016 etc
drwxr-xr-x. 2 root root 6 11月 5 2016 games
drwxr-xr-x. 2 root root 6 11月 5 2016 include
drwxr-xr-x. 2 root root 6 11月 5 2016 lib
drwxr-xr-x. 2 root root 6 11月 5 2016 lib64
drwxr-xr-x. 2 root root 6 11月 5 2016 libexec
drwxr-xr-x. 11 mysql mysql 197 11月 11 21:42 mysql
drwxr-xr-x. 11 root root 151 11月 11 20:49 nginx
drwxr-xr-x. 2 root root 19 11月 11 20:49 sbin
drwxr-xr-x. 5 root root 49 8月 10 03:42 share
drwxr-xr-x. 2 root root 6 11月 5 2016 src
[root@localhost local]# vim /etc/my.cnf
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
:wq
[root@localhost local]# echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
//在profile目錄定義環境變量
[root@localhost local]# echo 'export PATH' >> /etc/profile //將聲明環境變量寫入profile目錄
[root@localhost local]# source /etc/profile //使用source執行profile目錄
[root@localhost local]# echo $PATH //輸出環境變量,查看定義的環境變量是否被系統識別
/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost local]# cd /usr/local/mysql/
[root@localhost mysql]# bin/mysqld \
--initialize-insecure \ //初始化數據庫
--user=mysql \
--basedir=/usr/local/mysql \ //指定數據庫工作路徑
--datadir=/usr/local/mysql/data //指定數據存放位置
[root@localhost mysql]# cp usr/lib/systemd/system/mysqld.service /lib/systemd/system/
//復制啟動腳本到system管理器
[root@localhost mysql]# systemctl enable mysqld.service //設置開啟自啟動
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
[root@localhost mysql]# systemctl start mysqld.service //啟動服務
[root@localhost mysql]# netstat -ntap | grep 3306 //查看服務端口是否開啟
tcp6 0 0 :::3306 :::* LISTEN 24084/mysqld
[root@localhost mysql]# mysqladmin -u root -p password //設置數據庫密碼
Enter password: //輸入舊密碼,沒有密碼直接回車
New password: //設置新密碼
Confirm new password: //再次輸入新密碼
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@localhost ~]# yum install -y libjpeg libjpeg-devel libpng libpng-devel libxml2 libxml2-devel freetype freetype-devel zlib zlib-devel curl curl-devel openssl openssl-devel //安裝環境包
...//省略部分內容...
已安裝:
freetype-devel.x86_64 0:2.8-14.el7 libcurl-devel.x86_64 0:7.29.0-54.el7
libjpeg-turbo-devel.x86_64 0:1.2.90-8.el7 libpng-devel.x86_64 2:1.5.13-7.el7_2
libxml2-devel.x86_64 0:2.9.1-6.el7_2.3 openssl-devel.x86_64 1:1.0.2k-19.el7
...//省略部分內容...
完畢!
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
Discuz_X3.4_SC_UTF8.zip mysql-boost-5.7.20.tar.gz nginx-1.12.2.tar.gz php-7.1.20.tar.gz
[root@localhost mnt]# tar zxvf php-7.1.20.tar.gz -C /opt/ //解壓源碼包
[root@localhost mnt]# cd /opt/
[root@localhost opt]# ls
mysql-5.7.20 nginx-1.12.2 php-7.1.20 rh
[root@localhost opt]# cd php-7.1.20/
[root@localhost php-7.1.20]# ./configure \ //配置php
--prefix=/usr/local/php \ //定義安裝路徑
--with-mysql-sock=/usr/local/mysql/mysql.sock \ //關聯mysql數據庫
--with-mysqli \ //關聯MySQL客戶端
--with-zlib \ //支持壓縮
--with-curl \
--with-gd \ //支持圖像處理
--with-jpeg-dir \ //支持jpeg圖片
--with-png-dir \
--with-freetype-dir \ //支持字體處理
--with-openssl \ //支持安全功能
--enable-fpm \ //支持動態請求
--enable-mbstring \ //支持字符串處理
--enable-xml \ //支持xml格式
--enable-session \ //指出session會話
--enable-ftp \ //指出ftp功能
--enable-pdo \ //指出通用接口
--enable-tokenizer \ //支持tokenizer函數庫
--enable-zip //支持壓縮
[root@localhost php-7.1.20]# make && make install //制作安裝php
[root@localhost php-7.1.20]# cp php.ini-development /usr/local/php/lib/php.ini
//復制php配置文件到安裝的php目錄下
[root@localhost php-7.1.20]# vim /usr/local/php/lib/php.ini //編輯配置文件
...//省略部分內容...
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
; http://php.net/mysqli.default-socket
mysqli.default_socket = /usr/local/mysql.sock //找到此條目,輸入關聯的mysql數據路徑
...//省略部分內容...
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shanghai //找到此條目,設置時區
...//省略部分內容...
:wq
[root@localhost php-7.1.20]# /usr/local/php/bin/php -m //查看php默認模塊是否開啟
[PHP Modules]
Core
ctype
curl
...//省略部分內容...
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf //開啟fpm配置文件
[root@localhost etc]# vim php-fpm.conf //編輯配置文件
...//省略部分內容...
[global]
; Pid file
; Note: the default prefix is /usr/local/php/var
; Default Value: none
pid = run/php-fpm.pid //開啟此條目
...//省略部分內容...
:wq
[root@localhost etc]# cd php-fpm.d/
[root@localhost php-fpm.d]# ls
www.conf.default
[root@localhost php-fpm.d]# cp www.conf.default www.conf //開啟擴展配置文件
[root@localhost php-fpm.d]# /usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini //啟動php
[root@localhost php-fpm.d]# netstat -ntap | grep 9000 //查看端口是否開啟
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 35687/php-fpm: mast
[root@localhost php-fpm.d]# ln -s /usr/local/php/bin/* /usr/local/bin/
//將php命令建立軟鏈接到系統命令目錄
[root@localhost php-fpm.d]# vim /usr/local/nginx/conf/nginx.conf //編輯nginx配置文件
...//省略部分內容...
location ~ \.php$ { //找到此處條目,去掉注釋
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; //更改站點目錄
include fastcgi_params;
}
...//省略部分內容...
:wq
[root@localhost php-fpm.d]# systemctl stop nginx.service //停止nginx服務
[root@localhost php-fpm.d]# systemctl start nginx //啟動服務
[root@localhost php-fpm.d]# cd /usr/local/nginx/html/ //進入nginx站點目錄
[root@localhost html]# ls
50x.html index.html
[root@localhost html]# mv index.html index.php //將index.html更改為index.php
[root@localhost html]# ls
50x.html index.php
[root@localhost html]# vim index.php //編輯網頁內容
<?php
phpinfo();
?>
:wq
[root@localhost html]# mysql -u root -p //進入mysql數據庫
Enter password: //輸入密碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.20 Source distribution
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE DATABASE bbs; //創建bbs數據庫
Query OK, 1 row affected (0.02 sec)
mysql> GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';
//提權數據庫用戶bbsuser為管理員并設定密碼
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> GRANT all ON bbs.* TO 'bbsuser'@'localhost' IDENTIFIED BY 'admin123';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges; //刷新數據庫
Query OK, 0 rows affected (0.00 sec)
mysql> show databases; //查看數據庫內容
+--------------------+
| Database |
+--------------------+
| information_schema |
| bbs |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> quit //退出
Bye
[root@localhost html]# cd /mnt
[root@localhost mnt]# ls
Discuz_X3.4_SC_UTF8.zip mysql-boost-5.7.20.tar.gz nginx-1.12.2.tar.gz php-7.1.20.tar.gz
[root@localhost mnt]# unzip Discuz_X3.4_SC_UTF8.zip -d /opt/ //解壓到opt目錄
[root@localhost mnt]# cd /opt/
[root@localhost opt]# ls
dir_SC_UTF8 mysql-5.7.20 nginx-1.12.2 php-7.1.20 rh 說明.htm
[root@localhost opt]# cd dir_SC_UTF8/ //進入論壇目錄
[root@localhost dir_SC_UTF8]# ls
readme upload utility
[root@localhost dir_SC_UTF8]# cp -r upload/ /usr/local/nginx/html/bbs
//復制/opt目錄里的內容到html站點的bbs目錄中
[root@localhost dir_SC_UTF8]# cd /usr/local/nginx/html/bbs/ //進入bbs站點目錄
[root@localhost bbs]# chown -R root:nginx ./config/ //修改屬組
[root@localhost bbs]# chown -R root:nginx ./data/
[root@localhost bbs]# chown -R root:nginx ./uc_client/
[root@localhost bbs]# chown -R root:nginx ./uc_server/
[root@localhost bbs]# chmod -R 777 ./config/ //修改全部權限
[root@localhost bbs]# chmod -R 777 ./data/
[root@localhost bbs]# chmod -R 777 ./uc_client/
[root@localhost bbs]# chmod -R 777 ./uc_server/
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。