環境: php
VMware Virtual Machine : XGan63.cn html
IP: 192.168.31.63 (Bridge)mysql
已配置本地yum源 ---> /mntweb
已配置網絡yum源 ---> http://mirrors.aliyun.comsql
安裝前確保環境乾淨,避免軟件衝突形成影響shell
檢查環境:數據庫
which httpd #查看是否安裝httpd服務apache
chkconfig --list httpd #檢查httpd啓動項vim
chkconfig --list mysqld #檢查mysqld啓動項瀏覽器
which php #檢查php是否已安裝
rpm -qa | grep httpd #查看 httpd,php,mysql是否已安裝
rpm -qa | grep php
rpm -qa | grep mysql
一. 安裝 Apache,MySQL,PHP
yum -y install httpd mysql-server php php-mysql
# httpd是apache的web服務,提供web訪問服務
# mysql-server是數據庫服務,mysql是本地訪問數據客戶端程序,安裝server時,會被裝上的
# php 解析php網頁
# php-mysql php與mysql鏈接程序,是php能夠訪問數據庫
httpd數錯了,沒裝上,不過php依賴關係時,給裝上了
二. 配置環境
1. 配置apahce並測試php
設置開機啓動項
chkconfig httpd on
啓動服務,在客戶端訪問,測試
service httpd start
測試PHP,建立查看phpinfo()信息界面
echo "<?php phpinfo() ?> " >> /var/www/html/index.php
在宿主機中訪問地址192.168.31.63,結果以下:Ok
2. 配置Apache開啓虛擬主機實現
uc.xgan63.cn訪問ucenter;
www.xgan63.cn訪問ucenter_home;
2.1 在宿主機中,修改host添加域名信息,
使其可以解析域名uc.xgan63.cn和www.xgan63.cn
C:\Windows\System32\drivers\etc\hosts
192.168.31.63 uc.xgan63.cn
192.163.31.63 www.xgan63.cn
在命令行測試以下:
2.2 配置httpd服務,開啓虛擬主機:
vim /etc/httpd/conf/httpd.conf
修改以下:
NameVirtualHost *.80
修改以下:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/ucenter
ServerName uc.xgan63.cn
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/ucenter_home
ServerName www.xgan63.cn
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
2.3 重啓squid和httpd服務:
service httpd restart #httpd重啓
2.4 在宿主機中測試以下圖:Ok!!!
3. 配置mysql
chkconfig mysqld on #添加開機啓動
service mysqld start # 啓動mysqld服務
[root@xgan63 ~]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK #見到這兩個Ok表示初始化並啓動成功
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h xgan63.cn password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
mysql_secure_installation #運行安全配置初始化
[root@xgan63 ~]# mysql_secure_installation
...
Enter current password for root (enter for none): # 回車便可
OK, successfully used password, moving on...
...
Set root password? [Y/n] y # 設置root密碼
New password: # 輸入root密碼
Re-enter new password: # 再次輸入
... Success!...
...
Remove anonymous users? [Y/n] y # 刪除匿名用戶
... Success!
...
Disallow root login remotely? [Y/n] y # 禁止root用戶遠程鏈接
... Success!
Remove test database and access to it? [Y/n] y # 測試數據
- Dropping test database...
... Success!
...
- Removing privileges on test database...
... Success!
...
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
爲UCenter建立數據庫,和專門的維護用戶
安全起見,咱們應該在mysql中ucenter專門建立一個用戶用於維護數據庫,方法以下:
mysql -uroot -p123456 #命令行中,進入數據庫
create database ucenter; # 建立UCenter數據庫
create user ‘center’@’localhost’ identified by ‘shihuan1989’; #建立本機用戶,並設置密碼爲shihuan1989
grant all privileges on ucenter.* to ‘center’@’localhost’;#受權本機用戶center對於ucenter的全部權限
4. 下載UCenter_1.5.2_SC_UTF8.zip和UCenter_Home_2.0_SC_UTF8.zip
並安裝配置
UCenter_1.5.2 URL:
http://download.comsenz.com/UCenter/1.5.2/UCenter_1.5.2_SC_UTF8.zip
UCenter_Home_2.0 URL:
http://download.comsenz.com/UCenter_Home/2.0/UCenter_Home_2.0_SC_UTF8.zip
使用wget命令或經過瀏覽器下載到宿主機後使用Xshell上傳到服務器XGan63.cn
解壓縮UCenter和UCenter_Home到指定目錄
並將解壓後的upload目錄中的文件所有移動到對應的工做目錄下:
解壓UCenter並上傳文件到工做目錄:
unzip -d /usr/local/src/ucenter UCenter_1.5.2_SC_UTF8.zip
unzip -d /usr/local/src/ucenter_home UCenter_Home_2.0_SC_UTF8.zip
mv /usr/local/src/ucenter/upload/* /var/www/html/ucenter/.
mv /usr/local/src/ucenter_home/upload/* /var/www/html/ucenter_home/.
並賦予apache文件權限
chown -R apache:apache /var/www
安裝UCenter
在宿主機瀏覽器中訪問uc.xgan63.cn
點擊Please click here to install it.
上圖須知,php需開啓標籤功能
vim /etc/php.ini
short_open_tag=on #以下圖
保存退出,推出後,重啓httpd服務
service httpd restart
而後宿主機瀏覽器中F5刷新,點擊我贊成,以下圖
而後開機檢測運行環境以及,文件權限和依賴關係所有Ok,點擊下一步,以下圖:
開始安裝數據庫,填寫以前配置好的信息,並建立管理員密碼以下圖,點擊下一步:
出現,以下圖界面表示,已安裝成功!!!,點擊下一步:
嘗試輸入密碼,登陸
OK,UCenter安裝完成了
安裝UCenter_Home
在宿主機瀏覽器地址欄中,輸入www.xgan63.cn,
按圖,在服務器中操做以下:
mv /var/www/html/ucenter_home/config.new.php /var/www/html/ucenter_home/config.php
而後在宿主機瀏覽器中按F5刷新,
出現以下圖(檢測文件訪問權限,都沒有問題):(點擊受權協議,並開始安裝)
而後,出現以下圖,讓咱們輸入UCenter信息(地址和創世密碼),輸入後點擊提交:
出現以下圖,找不到UCenter,輸入IP地址,並點擊確認
點擊下一步,開始安裝數據庫
填入已經設置好的數據庫信息,以下圖,並點擊設置完畢:
UCenter Home鏈接到數據庫並建立數據庫結構,添加默認數據後,出現以下圖:
(填寫想要建立的管理員帳戶和密碼後,點擊開通管理員空間)
出現以下圖界面,Ok UCenter Home已安裝完成,可點擊 進入個人空間或進入管理平臺進行管理
---> 進入個人空間
---> 進入管理平臺
Ok,到此時,咱們的UCenter和UCenter_Home已搭建完成了!!!