2017年5月3日 星期三

CentOS 7 環境搭建指令懶人包 (Apache+MariaDB)

為了以後安裝機器著想,先幫自己記錄好指令。


1. 開防火牆,否則無法連線:

firewall-cmd --get-active-zones
firewall-cmd --zone=dmz --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

2. Apache
setenforce 0
sudo yum clean all && sudo yum -y update
sudo yum -y install httpd
sudo systemctl start httpd
sudo systemctl enable httpd

查看 Apache 狀態:
sudo systemctl status httpd

修改 /etc/httpd/conf/httpd.conf 檔案:
vi /etc/httpd/conf/httpd.conf

進入 vim 直接用 " /AllowOverride None" + Enter 查找項目,覆蓋:
AllowOverride None

改為:
AllowOverride All

--
3. MariaDB
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation

所有選項都 Y 。


4. PHP
sudo yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap php-mcrypt curl zlib

 --Options 如果要安裝 phpMyAdmin:
sudo yum -y install epel-release
sudo yum -y install phpmyadmin
sudo systemctl restart httpd.service


5. Problem

如果你進不去 phpMyAdmin ,可以直接用 mysql 指令做查詢動作:
mysql -u [username] -p

接著會詢問輸入密碼,完成就可以登入。

--
Application 無法存取 php 什麼的,記得 chmod 先開起來再說:
sudo chmod -R 777 ./html

--
如果網站狂噴 403,試試看重設:
restorecon -r /var/www/html

--
桌面版 centos 記憶體噴掉,試試看關掉 gdm:
service gdm stop
--
Wordpress 之類的系統,有可能噴出要你給 FTP 資料的訊息,這可能是 apache 權限不夠,cd 到 /var/www/html 之前的目錄,也就是如果你網站放在 /var/www/html 裡面,請回到 /var/www : [sudo chown -R $USER : $USER]
sudo chown -R apache: html
--
需要 MOD_SSL with php?
yum install mod_ssl
記得開防火牆

firewall-cmd --get-active-zones
firewall-cmd --zone=dmz --add-port=443/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload
設定 config:

vi /etc/httpd/conf.d/ssl.conf
修改:
# Use name-base virtual hosting
NameVirtualHost *:443

重新開機:
service httpd restart


Vultr 安裝預先指令集:
firewall-cmd --get-active-zones
firewall-cmd --zone=dmz --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
setenforce 0
sudo yum clean all && sudo yum -y update
sudo yum -y install httpd
sudo systemctl start httpd
sudo systemctl enable httpd
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation
sudo yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap php-mcrypt curl zlib
sudo yum -y install epel-release
sudo yum -y install phpmyadmin
sudo systemctl restart httpd.service

不過最後還是要自己修改 httpd 文件,然後 restart httpd。

Reference:
http://stackoverflow.com/questions/24729024/centos-7-open-firewall-port
https://www.unixmen.com/install-opencart-centos-7-linux/
https://askubuntu.com/questions/253466/why-am-i-frequently-getting-this-cannot-allocate-memory-error
https://www.centos.org/forums/viewtopic.php?t=6834
http://stackoverflow.com/questions/39012285/centos-7-how-to-stop-start-gnome-desktop-from-command-line
https://wordpress.org/support/topic/final-step-asks-for-connection-information-via-ftp-but-im-on-aws/
https://www.chrisabernethy.com/why-wordpress-asks-connection-info/
https://codex.wordpress.org/Managing_Plugins
http://dev.antoinesolutions.com/apache-server/mod_ssl

沒有留言:

張貼留言

© Mac Taylor, 歡迎自由轉貼。
Background Email Pattern by Toby Elliott
Since 2014