標籤:
CentOS使用yum源中內建的rpm包安裝LAMP環境。這是Linux下安裝LAMP的環境一種最基本最簡便的方式。新手可以從容安裝使用。
1. 安裝基礎包(可選安裝)
yum install -y wget zip unzip gzip
yum install -y python ruby perl
yum install -y gc gcc gcc-c++
2. 安裝php及其相關組件
yum install -y php php-gd
yum install -y php-mbstring php-mcrypt php-mysql php-pdo
3. 啟動httpd伺服器
service httpd start
chkconfig httpd on 設定開機自動啟動
伺服器www目錄位址/var/www/html/
4. 安裝mysql
yum install -y mysql mysql-server
[[email protected] html]# service mysqld start
5. 配置mysql
根據提示運行
/usr/bin/mysql_secure_installation
按照提示對mysql進行配置,包括root密碼設定等等。
chkconfig mysqld on 設定開機自動啟動
6. 安裝phpmyadmin
下載phpmyadmin相應版本 https://www.phpmyadmin.net/files/
將zip包copy到/var/www/html/目錄,並解壓縮重新命名為phpmyadmin
例如:
wget https://files.phpmyadmin.net/phpMyAdmin/3.5.8.2/phpMyAdmin-3.5.8.2-all-languages.zip
unzip phpMyAdmin-3.5.8.2-all-languages.zip -d /var/www/html/
mv /var/www/html/phpMyAdmin-3.5.8.2-all-languages /var/www/html/phpmyadmin
訪問 http://youripaddress/phpmyadmin/ 就可以根據 5. 配置mysql 中設定的root密碼登入
7. 防火牆問題
購買的伺服器一般鏡像安裝後都會預設開啟22,80等常用連接埠。
自己安裝centos到特定機器或vmware虛擬機器安裝的時候可能出現iptables沒有配置導致80連接埠無法訪問的問題。
臨時禁用iptables的方法(重啟機器後失效),使用命令 service iptables stop
千萬不要在生產環境中這麼做!
---------------------------------------------------
初次運行 service mysqld start 會有下面的提示,此處做好記錄以備以後查看,
對資料庫問題修複有至關重要的作用!!
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
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 localhost.localdomain 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 ]
CentOS使用yum源中內建的rpm包安裝LAMP環境