LAMP環境配置安裝注意安裝步驟及說明事項。php
Linux + apache+mysql+phphtml
解決:mysql
關閉selinuxlinux
vi /etc/selinux/configc++
內容修改成: selinux=disableweb
以後重啓reboot。sql
下圖分別爲selinux關閉前 和 關閉後:shell
http://rpmfind.net數據庫
gccapache
cloog-ppl
ppl(libppl.so.7/libppl_c.so.2)
cpp
mpfr(libmpfr.so.1)
gcc-c++
libstdc++-devel
mpfr-2.4.1-6.el6.i686.rpm和ppl-0.10.2-11.el6.i686.rpm
快捷鍵rz sz:
rz、sz命令沒找到?
安裝lrzsz便可:
shell># yum -y install lrzsz
shell>## cd /home/jinnan/tar
shell># tar –zxvf zlib-1.2.5.tar.gz
shell># cd zlib-1.2.5
shell># ./configure //這個配置編譯命令不要加目錄參數
shell>#make && make install
shell># cd /home/jinnan/tar
shell># tar -jxvf httpd-2.2.19.tar.bz2
shell># cd httpd-2.2.19
shell>#./configure --prefix=/usr/local/http2 \
--enable-modules=all \
--enable-mods-shared=all \
--enable-so
shell># make && make install
啓動Apache
shell># /usr/local/http2/bin/apachectl start/stop/restart
#測試apache
瀏覽器打開: http://虛擬機IP
看到 "it works!",即爲成功
配置虛擬主機
1)配置host文件
打開C:/windows/system32/drivers/etc/hosts 文件
增長域名記錄
如:
192.168.9.38 www.ec1.com
192.168.9.38 www.ec2.com
2) 增長虛擬主機
vi /usr/local/http2/conf/httpd.conf
取消# Include conf/extra/httpd-vhosts.conf
這一行前面的#號
保存退出
vi /usr/local/http2/conf/extra/httpd-vhosts.conf
增長虛擬主機記錄
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/http2/htdocs/ec1"
ServerName www.ec1.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/local/http2/htdocs/ec2"
ServerName www.ec2.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/shop"
ServerName www.ec1.com
</VirtualHost>
注意:/var/www/shop 以上三個目錄var www shop 的其餘用戶必須有x可執行權限
3)
shell># cd /usr/local/http2/htdocs
shell># mkdir ec1 ec2
shell># echo this is ec1.com > ec1/index.html
shell># echo this is ec2.com > ec2/index.html
4)重啓apache
/usr/local/http2/bin/apachectl restart
5)瀏覽器打開www.ec1.com,和www.ec2.com
看到不一樣的網站內容,虛擬主機建立完畢!
安裝圖形庫,爲編譯PHP作準備
libxml2-2.7.2.tar.gz
jpegsrc.v8b.tar.gz
libpng-1.4.3.tar.gz
freetype-2.4.1.tar.gz
gd-2.0.35.tar.gz
shell># cd /home/jinnan/tar
shell># tar zxvf libxml2-2.7.2.tar.gz
shell># cd libxml2-2.7.2
shell>#./configure --prefix=/usr/local/libxml2 \
--without-zlib
shell># make && make install
shell># cd /home/jinnan/tar
shell># tar -zxvf jpegsrc.v8b.tar.gz
shell># cd jpeg-8b
shell>#./configure --prefix=/usr/local/jpeg \
--enable-shared --enable-static
shell># make && make install
--enable-shared 把jpeg須要的函數庫程序都編譯到該軟件裏邊
優勢:函數調用速度快
缺點:軟件自己比較大
--enable-static 靜態方式函數處理,須要什麼函數,立刻include來
優勢:軟件自己比較小
缺點:函數調用速度慢
shell># cd /home/jinnan/tar
shell># tar zxvf libpng-1.4.3.tar.gz
shell># cd libpng-1.4.3
shell>#./configure #和zlib同樣不要帶參數,讓它默認安裝到相應目錄
shell># make && make install
shell># cd /home/jinnan/tar
shell># tar zxvf freetype-2.4.1.tar.gz
shell># cd freetype-2.4.1
shell>#./configure --prefix=/usr/local/freetype
shell># make && make install
shell># cd /home/jinnan/tar
shell># tar -zvxf gd-2.0.35.tar.gz
shell># mkdir -p /usr/local/gd
shell># cd gd-2.0.35
shell>#./configure --prefix=/usr/local/gd \
--with-jpeg=/usr/local/jpeg/ \
--with-png --with-zlib \
--with-freetype=/usr/local/freetype
shell># make && make install
shell># cd /home/jinnan/tar
shell># tar -jxvf php-5.3.6.tar.bz2
shell># cd php-5.3.6
shell>#./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/http2/bin/apxs \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-freetype-dir=/usr/local/freetype \
--with-gd=/usr/local/gd \
--with-zlib --with-libxml-dir=/usr/local/libxml2 \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir \
--enable-mbstring=all \
--enable-mbregex \
--enable-shared
shell># make && make install
複製php.ini配置文件到指定目錄
shell># cp php.ini-development /usr/local/php/lib/php.ini
配置Apache使其支持php
vi /usr/local/http2/conf/httpd.conf
1) 在httpd.conf(Apache主配置文件)中增長:
AddType application/x-httpd-php .php
2) 找到下面這段話:
<IfModule dir_module>
DirectoryIndex index.php
DirectoryIndex index.html
</IfModule>
在index.html 前面添加index.php
3) 創建php測試網頁
vi /usr/local/apache2/htdocs/index.php
輸入以下內容:
<?php
phpinfo();
?>
4) 重啓apache
shell># /usr/local/http2/bin/apachectl restart
5) 再次瀏覽器查看http://虛擬機IP
若是看到php信息,工做就完成了!
shell># cd /home/jinnan/tar
shell># tar zxvf cmake-2.8.5.tar.gz
shell># cd cmake-2.8.5
shell># ./bootstrap
shell># make && make install
shell># cd /home/jinnan/tar
shell># tar zxvf mysql-5.5.17.tar.gz
shell># cd mysql-5.5.17
shell># cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
(準備安裝到那裏
數據存儲目錄
默認的字符集
校對字符集)
(報錯就安裝ncurses-devel)
shell># mount .....掛載光盤/
shell># rpm -ivh ncurses-devel-5.7-3.20090208.el6.i686.rpm
shell># rm -f CMakeCache.txt //刪除該文件
shell># cmake 。。。 。。。 //從新cmake
shell># make && make install
shell># cp support-files/my-medium.cnf /etc/my.cnf
shell># useradd mysql (該mysql用戶會存在於同名的組下)
shell># chmod +x /usr/local/mysql
(數據庫用戶信息不當心刪除光了,刪除data目錄,今後開始執行如下指令,直至結束)
shell># chown -R mysql.mysql /usr/local/mysql
初始化mysql數據庫
shell># /usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data &
把mysql安裝文件(除了data)的主人都改成root,避免數據庫恢復爲出廠設置。
shell># chown -R root /usr/local/mysql
shell># chown -R mysql /usr/local/mysql/data
& 後臺運行mysql服務
shell># /usr/local/mysql/bin/mysqld_safe --user=mysql &
//查看mysql是否有啓動
shell># ps –A | grep mysql
測試數據庫
shell># /usr/local/mysql/bin/mysql –u root
mysql> show databases;
接上步,修改mysql密碼(可不作此步,默認無密碼)
mysql> UPDATE user SET Password=password('123456') WHERE user='root';
mysql> flush privileges;
shell># cp 安裝包解壓目錄/support-files/mysql.server /etc/init.d/mysqld
shell># chmod +x /etc/init.d/mysqld
shell># chkconfig --add mysqld
shell># chkconfig mysqld on //設置開機自啓動
配置文件路徑:
shell># vi /etc/rc.d/rc.local
在 文件中增長啓動相關服務的命令以下:
/usr/local/http2/bin/apachectl start
/usr/local/mysql/bin/mysqld_safe --user=mysql &
service vsftpd start
從新安裝apache啓動失敗
[root@localhost httpd-2.2.19]# /usr/local/http2/bin/apachectl restart
httpd not running, trying to start
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
緣由是80端口被佔用
解決:
查看80端口使用狀況
[root@localhost httpd-2.2.19]# netstat -lnp|grep 80
tcp 0 0 :::80 :::* LISTEN 28195/httpd
unix 2 [ ACC ] STREAM LISTENING 6580 1957/gpm /dev/gpmctl
unix 2 [ ACC ] STREAM LISTENING 5422 1800/pcscd /var/run/pcscd.comm
查看80的使用者是誰端口
[root@localhost httpd-2.2.19]# ps 28195
PID TTY STAT TIME COMMAND
28195 ? Ss 0:00 /usr/local/http2/bin/httpd -k restart
通過分析知道了80端口被系統的一個進程佔用,這個進程是舊的apache服務
將這個進程殺之
[root@localhost httpd-2.2.19]# kill -9 28195
[root@localhost httpd-2.2.19]#
killall httpd 殺死所有的httpd進程