開始之前,更新一下系統(tǒng) apt-get update apt-get upgrade –show-upgraded
目錄 1.安裝/配置Apache 2.安裝/配置MySQL 3.安裝/配置PHP
一、安裝/配置Apache
1.安裝Apache apt-get install apache2
2.確保開啟偽靜態(tài)功能 a2enmod rewrite
3.設(shè)置虛擬主機(jī)
推薦如下方式
在目錄/etc/apache2/sites-available/下創(chuàng)建形如example.com的文件(按照綁定域名的數(shù)量可創(chuàng)建多個(gè)文件),內(nèi)容如下(請參照修改)
<VirtualHost *:80> ???? ServerAdmin webmaster@example.com ???? ServerName example.com ???? ServerAlias www.example.com ???? DocumentRoot /srv/www/example.com/public_html/ ???? ErrorLog /srv/www/example.com/logs/error.log ???? CustomLog /srv/www/example.com/logs/access.log combined </VirtualHost>
根據(jù)上面的配置,你的網(wǎng)站目錄應(yīng)該都在/srv/www下,ErrorLog和CustomLog并不是必選,但一旦設(shè)定,相關(guān)目錄必須存在(自行創(chuàng)建,命令如下,) mkdir -p /srv/www/example.com/public_html mkdir /srv/www/example.com/logs
設(shè)定生效 a2ensite example.com
4.重啟Apache /etc/init.d/apache2 reload
如需停用該網(wǎng)站,可使用如下命令 a2dissite example.com
注意:啟用/停用網(wǎng)站,都需要重啟Apache(命令如上面所示)
二、安裝/配置MySQL
1.安裝MySQL apt-get install mysql-server
安裝過程會(huì)提示設(shè)定密碼,相關(guān)設(shè)置存儲(chǔ)于/etc/mysql/my.cnf
2.安全設(shè)置 mysql_secure_installation
3.MySQL常用命令
登錄 mysql -u root -p
創(chuàng)建數(shù)據(jù)庫example,并授權(quán)給用戶newuser(用戶密碼newpassword) create database example; grant all on example.* to ‘newuser’ identified by ‘newpassword’;
退出MySQL quit
三、安裝/配置PHP
1.安裝PHP apt-get install php5 php-pear php5-suhosin
PHP配置文件位于/etc/php5/apache2/php.ini
2.修改PHP配置/etc/php5/apache2/php.ini max_execution_time = 30 memory_limit = 64M error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR display_errors = Off log_errors = On error_log = /var/log/php.log register_globals = Off
3.安裝PHP對(duì)MySQL的支持 apt-get install php5-mysql
4.最后,重啟Apache /etc/init.d/apache2 restart




VPS套餐介紹-scaled.png)





房清倉獨(dú)服月付-45-起,EPYC-9754-DDR5-NVMe10Gbps大帶寬頂配-VPS-月付9.34起.png)
早鳥促銷-scaled.png)








優(yōu)惠及服務(wù)介紹-scaled.png)
