在好友的推薦下購買了QuickWeb的VPS,512 MB內存,25 GB空間,500 GB流量,于是開始折騰起來。
登陸后臺,選擇安裝了CentOS 5.5 (32-bit),然后根據Linode的文檔安裝了LAMP。
SSH登陸你的VPS,一般用PuTTY,IP為你的VPS的IP,用戶名是root,密碼是郵件里的密碼。
AMP(Apache + MySql + PHP)網站服務器工作環境搭建
1、安裝/配置 Apache Web Server
1 2 | yum update yum install httpd |
備份 Apache 配置文件
1 | cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup |
配置虛擬主機
1 | vi /etc/httpd/conf.d/vhost.conf |
1 2 3 4 5 6 7 8 9 10 | NameVirtualHost 173.231.xxx.xxx:80 <VirtualHost domain.com:80> ServerAdmin domain@domain.com ServerName domain.com ServerAlias www.domain.com DocumentRoot /home/www/domain.com/public_html/ ErrorLog /srv/home/domain.com/logs/error.log CustomLog /srv/home/domain.com/logs/access.log combined </VirtualHost> |
創建文件夾
1 2 | mkdir -p /home/www/domain.com/public_html mkdir -p /home/www/domain.com/logs |
啟動Apache
1 | /etc/init.d/httpd start |
配置設置為開機啟動
1 | /sbin/chkconfig --levels 235 httpd on |
重啟Apache
1 | /etc/init.d/httpd reload |
2、安裝/配置 MySQL
1 | yum install mysql-server |
配置設置為開機啟動 :
1 | /sbin/chkconfig --levels 235 mysqld on |
啟動/重啟 MySQL
1 | /etc/init.d/mysqld start |
配置MySQL / 建立數據庫
1 2 3 4 5 | mysql_secure_installation (注意修改密碼、刪除示例) mysql -u root -p (登入) create database DBNAME; (創建) grant all on DBNAME.* to 'DBUSER' identified by 'DBPASS'; (賦與權限 / 用戶名、密碼創建) quit (退出) |
3、安裝/配置 PHP
1 | yum install php php-pear |
配置PHP
1 | vi /etc/php.ini |
1 2 3 4 5 6 7 | 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 max_execution_time = 300 memory_limit = 64M register_globals = Off |
安裝 PHP5-Mysql 包
1 | yum install php-mysql |
如需安裝FTP和PHPMYADMIN,可參考QuickWeb VPS之vsftpd,phpmyadmin安裝
還有數據備份QuickWeb VPS設置及數據備份