安裝完CentOS 可以輸入nmtui 來執行網路設定
我個人是覺得比編譯 /etc/sysconfig/network-scripts檔案快多了
本篇軟體版本
nginx:1:1.12.2-1.e17
PHP-FPM:5.4.16-43.e17_4
安裝下載軟體
yum -y install epel-release mariadb mariad-server php php-fpm
yum -y install phpmyadmin nginx
設定防火牆
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
設定nginx mariadb php-fpm服務
sudo systemctl enable nginx mariadb php-fpm
sudo systemctl restart nginx mariadb php-fpm
設定nginx設定檔 開啟PHP服務 重點是黃色部分請修改成自己IP
vi /etc/nginx/nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 5;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 10240;
}
http {
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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 1.1.1.1:80;
server_name 1.1.1.1;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
修改php-fpm
vi /etc/php-fpm.d/www.conf
;user = apache
user = nginx
;group = apache
group = nginx
新增一個文件在這測試
sudo vi /usr/share/nginx/html/index.php
文件程式碼
<?php phpinfo(); ?>
設定DB安全性
mysql_secure_installation
預設密碼是空白,直接Enter 進去更改密碼 (要輸入兩次)
1.移除匿名使用者帳戶
2.拒絕Root遠端操作
3.移除測試資料庫
4.重新讀取資料庫
reboot
進首頁應該正常 接著進入phpmyadmin測試
vi /etc/phpMyAdmin/config.inc.php
把認證方式$cfg['servers'][$i]['auth_type'] 從Cookie改成 http
然後輸入reboot 進入系統 用systemctl status 確認 mariadb php-fpm nginx 都是開機啟動
在瀏覽器輸入ip + /phpMyAdmin/index.php 出現如下畫面
mysql_secure_installation
預設密碼是空白,直接Enter 進去更改密碼 (要輸入兩次)
1.移除匿名使用者帳戶
2.拒絕Root遠端操作
3.移除測試資料庫
4.重新讀取資料庫
reboot
進首頁應該正常 接著進入phpmyadmin測試
vi /etc/phpMyAdmin/config.inc.php
把認證方式$cfg['servers'][$i]['auth_type'] 從Cookie改成 http
建立指向
ln -s /usr/share/phpMyAdmin/ /usr/share/nginx/html/
ln -s /usr/share/phpMyAdmin/ /usr/share/nginx/html/
然後輸入reboot 進入系統 用systemctl status 確認 mariadb php-fpm nginx 都是開機啟動
在瀏覽器輸入ip + /phpMyAdmin/index.php 出現如下畫面
沒有留言:
張貼留言