文章出處
文章列表
開始安裝軟件了,我們需要安裝的軟件有apache,php和MySQL。
ps:如果你購買的是北京的服務器,有個安全組需要設置,我全部用的默認設置,暫時還沒發現會有什么影響。
首先關閉SELINUX(SELINUX是一個安全子系統,它能控制程序只能訪問特定文件。如果不關閉,你可能訪問文件受限):
vi /etc/selinux/config
#SELINUX=enforcing #注釋掉
#SELINUXTYPE=targeted #注釋掉
SELINUX=disabled #增加
:wq!#保存退出
shutdown -r now#重啟系統
然后安裝apache
yum install httpd #根據提示,輸入Y安裝即可成功安裝
/etc/init.d/httpd start#啟動Apache
備注:Apache啟動之后會提示錯誤:
正在啟動 httpd:httpd: Could not reliably determine the server's fully qualif domain name, using ::1 for ServerName
解決辦法:
vi /etc/httpd/conf/httpd.conf #編輯
找到 #ServerName www.example.com:80
修改為 ServerName www.jbaobao.net:80 #這里設置為你自己的域名,如果沒有域名,可以設置為localhost
:wq! #保存退出
chkconfig httpd on #設為開機啟動
/etc/init.d/httpd restart #重啟Apache
安裝mysql
yum install mysql mysql-server #詢問是否要安裝,輸入Y即可自動安裝,直到安裝完成
/etc/init.d/mysqld start #啟動MySQL
chkconfig mysqld on #設為開機啟動
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷貝配置文件(注意:如果/etc目錄下面默認有一個my.cnf,直接覆蓋即可
mysql應該還缺授權和設置密碼 可以移步我的 【阿里云產品】
然后為mysql的root賬號設置密碼(默認的是空)
mysql_secure_installation回車
這里需要注意的是,如果你是新安裝的mysql,會彈出如下提示:
In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here.
Enter current password for root (enter for none):
大概意思就是如果你是新安裝的話,你的默認密碼是空,直接按enter鍵就可以了
然后設置新的密碼,輸入兩次。
再然后,會有若干個提示:
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
大概意思是,mysql會默認創建一個匿名用戶,方便你測試什么的,現在問你要不要刪掉它,果斷刪掉
Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
大概意思是,root用戶默認只能訪問localhost,以防止有人猜你的密碼。。。問你是否禁止root登陸,也選yes,雖然基本上不會有人來猜吧。。。
By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.
Remove test database and access to it? [Y/n] y
大概意思是,mysql默認創建了一個名為test的數據庫,這個庫任何人都可以訪問,問你是不是要把它刪掉,也刪掉。
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
大概意思是,上面所有的修改是否馬上生效,選y
總之就是一路Yes。。。。
最后出現:Thanks for using MySQL!
MySql密碼設置完成,重新啟動 MySQL:
/etc/init.d/mysqld restart #重啟
最后一步,安裝php
yum install php #根據提示輸入Y直到安裝完成
#安裝PHP組件,使 PHP5 支持 MySQL
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt #這里選擇以上安裝包進行安裝,根據提示輸入Y回車
/etc/init.d/mysqld restart #重啟MySql
/etc/init.d/httpd restart #重啟Apche
OK,到這里,所有的軟件都安裝完了,現在測試一下。
默認的,你會有一個www的文件夾,里面有個html的文件夾,你的默認訪問路徑就是這里。
cd /var/www/html 需要把項目拷貝到里面 不要去修改路徑 vi index.php #編輯輸入下面內容 <?php echo "hello my server!"; ?> :wq! #保存退出
文章列表
全站熱搜