1.更新套件
yum upgrade -y #升級
2.安裝epel資源庫
yum install epel-release -y #安裝擴充資源庫
3.更新倉庫版本
yum update -y #更新
4.安裝nginx,並設定開機啟用
yum install nginx -y #安裝nginx
systemctl start nginx #啟用nginx
systemctl status nginx
systemctl enable nginx
systemctl start nginx #啟用nginx
systemctl status nginx
systemctl enable nginx
5.設定http & https允許通過防火牆
firewall-cmd --permanent --zone=public --add-port=80/tcp #開啟80port的防火牆
firewall-cmd --permanent --zone=public --add-port=443/tcp #開啟443port的防火牆
firewall-cmd --reload #重啟firewalld服務
firewall-cmd --permanent --zone=public --add-port=443/tcp #開啟443port的防火牆
firewall-cmd --reload #重啟firewalld服務
6.安裝mariadb,設定開機啟用,並設定mariadb參數配置
yum install mariadb-server mariadb -y
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
- Enter current password for root (enter for none): Enter
- Set root password? [Y/n] Y
- Remove anonymous users? [Y/n] n
- Disallow root login remotely? [Y/n] n
- Remove test database and access to it? [Y/n] n
- Reload privilege tables now? [Y/n] Y
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
- Enter current password for root (enter for none): Enter
- Set root password? [Y/n] Y
- Remove anonymous users? [Y/n] n
- Disallow root login remotely? [Y/n] n
- Remove test database and access to it? [Y/n] n
- Reload privilege tables now? [Y/n] Y
7.設定mariadb配置文件
vi /etc/my.cnf
#加入-------------------
[mysqld]
bind-address = 127.0.0.1
-------------------
#加入-------------------
[mysqld]
bind-address = 127.0.0.1
-------------------
8.安裝PHP & PHP-FPM
yum install centos-release-scl -y
yum install rh-php71 rh-php71-php-fpm rh-php71-php-mysqlnd -y
yum install rh-php71 rh-php71-php-fpm rh-php71-php-mysqlnd -y
9.設定PHP-FPM配置文件,並設定開機啟用
vi /etc/opt/rh/rh-php71/php-fpm.d/www.conf
#修改設定檔-------------------
listen = 127.0.0.1:9000
user = nginx
group = nginx
-------------------
#修改設定檔-------------------
listen = 127.0.0.1:9000
user = nginx
group = nginx
-------------------
systemctl start rh-php71-php-fpm
systemctl enable rh-php71-php-fpm
systemctl enable rh-php71-php-fpm
10.修改php.ini配置文件
vi /etc/opt/rh/rh-php71/php.ini
#修改設定檔-------------------
cgi.fix_pathinfo=0
-------------------
#修改設定檔-------------------
cgi.fix_pathinfo=0
-------------------
11.設定nginx配置文件,並套用php-fpm解析器
vi /etc/nginx/nginx.conf
#修改設定檔-------------------
#修改設定檔-------------------
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ .php$ {
try_files $uri =404;
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
-------------------12.重啟nginx & PHP 套用設定,與建立配置文件目錄
systemctl restart rh-php71-php-fpm
systemctl restart nginx
mkdir /etc/nginx/sites-available
mkdir /etc/nginx/sites-enabled
systemctl restart nginx
mkdir /etc/nginx/sites-available
mkdir /etc/nginx/sites-enabled
13.設定nginx配置文件
沒有留言:
張貼留言