CentOS 7 安裝 WordPress,PHP,Nginx,MySQL(MariaDB)

來源:互聯網
上載者:User

標籤:git   服務   adb   系統   inf   unit   ati   files   ice   

主要資料參考:https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7

 

1、安裝 nginx:

yum install nginx  使用 yum 安裝

systemctl start nginx  開啟 nginx

systemctl enable nginx  跟隨系統啟動

 

2、安裝 MySQL(MariaDB)

yum install mariadb-server mariadb  使用 yum 安裝

systemctl start mariadb  啟動資料庫

systemctl enable mariadb  開機啟動

mysql_secure_installation  設定安全性原則,會詢問以下5個問題

  a)為root使用者佈建密碼
  b)刪除匿名帳號
  c)取消root使用者遠程登入
  d)刪除test庫和對test庫的存取權限
  e)重新整理授權表使修改生效

mysql -u root -p  串連資料庫

create database wordpress;  串連資料庫後使用命令操作資料庫

 

3、安裝 PHP

yum install php php-mysql php-fpm  安裝 PHP 和必須的串連 MySQL 和 Nginx 的擴充

vi /etc/php.ini  配置 PHP:

  cgi.fix_pathinfo=0  這行前的分號去掉,將1改為0

vi /etc/php-fpm.d/www.conf  編輯服務器串連配置:

  listen = /var/run/php-fpm/php-fpm.sock  將 listen 的值改為此值

  listen.owner = nobody  這行前的分號去掉

  listen.group = nobody  這行前的分號去掉

  user = nginx
  group = nginx  將這兩行的值由 apache 改為 nginx

systemctl start php-fpm

systemctl enable php-fpm

 

4、配置 Nginx 到 PHP

vi /etc/nginx/conf.d/wordpress.conf

server {    listen       80;    server_name  tirion.me www.tirion.me;    # note that these lines are originally from the "location /" block    root   /home/web/wordpress;  # 配置 wordpress 的目錄路徑    index index.php index.html index.htm;    location / {        try_files $uri $uri/ =404;    }    error_page 404 /404.html;    error_page 500 502 503 504 /50x.html;    location = /50x.html {        root /usr/share/nginx/html;    }    location ~ \.php$ {        try_files $uri =404;        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;        fastcgi_index index.php;        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;        include fastcgi_params;    }}

systemctl restart nginx


5、安裝 FTP

yum install vsftpd  安裝 FTP 服務

systemctl start vsftpd.service

systemctl enable vsftpd.service

vi /etc/vsftpd/vsftpd.conf  修改 FTP 配置:

  anonymous_enable=NO  這行改為 NO,不允許匿名登入

允許 root 使用者使用 FTP:

  去掉或注釋掉 /etc/vsftpd/ftpusers 中的root

  去掉或注釋掉 /etc/vsftpd/user_list 中的root

配置 iptables:

  iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT

systemctl restart vsftpd.service  重啟 FTP 服務

 

6、安裝 WordPress

1) 從 https://cn.wordpress.org/ 下載 WordPress 安裝包,解壓後通過 FTP 上傳到伺服器相應的目錄,這裡就是 /home/web/wordpress

2) chmod 777 -R wordpress  給 WordPress 許可權

3) 通過 url 訪問:http://tirion.me/wp-admin/install.php 進行自動安裝

4) 根據需要進行配置 MySQL 串連的使用者名稱、密碼、使用的資料庫名,進行安裝即可

CentOS 7 安裝 WordPress,PHP,Nginx,MySQL(MariaDB)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.