您好,登錄后才能下訂單哦!
LAMP平臺(tái)部署與應(yīng)用
一 安裝Apache服務(wù)
1 刪除rpm方式安裝的httpd
rpm -e httpd --nodeps
2 安裝支持的軟件包
yum -y install apr apr-devel cyrus-sasl-devel expat-devel libdb-devel openldap-devel apr-util-devel apr-util pcre-devel pcre
結(jié)果如圖:
3 源碼編譯及安裝
上傳 rz httpd……
解壓 tar zxf httpd…… -C /usr/src
cd /usr/src/httpd……
配置及編譯安裝
./configure --prefix=/usr/local/httpd –enable-so –enable-rewrite –enable-charset-lite –enable-cgi && make && make install
添加系統(tǒng)服務(wù)
vim /lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid
ExecStart=/usr/local/bin/apachectl $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=graphical.target
4 啟動(dòng)系統(tǒng)服務(wù)
systemctl start(stop) httpd
systemctl enable httpd 開(kāi)機(jī)自啟
若出現(xiàn):Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
查看配置文件,保證無(wú)錯(cuò)的情況下,做優(yōu)化連接
ln -s /usr/local/httpd/bin/* /usr/local/bin/
結(jié)果如圖:
Vim /usr/local/httpd/conf/httpd.conf
二 安裝啟動(dòng)MySQL
1 yum –y install ncurses-devel
2 安裝cmake編譯安裝包
Rz 上傳
Tar zxf cmake..
Cd cmake…
./configure && gmake && gmake install
3 源碼編譯及安裝
創(chuàng)建組用戶 groupadd mysql
創(chuàng)建用戶 useradd –M –s /sbin/nologin mysql –g mysql
解壓 tar zxf mysql… -C /usr/src
配置 cd /usr/src/mysql….
cmake –DCMAKE_INSTALL_PREFIX=/usr/local/mysql –DSYSCONFDIR=/etc –DDEFAULT_CHARSET=utf8 –DDEFAULT_COLLATION=utf8_general_ci –DWITH_EXTRA_CHARSETS=all
編譯安裝 make && make install
4 安裝后的調(diào)整
權(quán)限設(shè)置 chown –R mysql:mysql /usr/local/mysql
建立配置文件:
CentOS 7 默認(rèn)支持MariaDB數(shù)據(jù)庫(kù),系統(tǒng)默認(rèn)的/etc/my.cnf為MariaDB的配置
文件因此需要將原本的文件替換為MySQL的
Rm –rf /etc/my.cnf
Cp support-files/my-default.cnf /etc/my.cnf
初始化數(shù)據(jù)庫(kù)
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
設(shè)置變量環(huán)境
Echo “PATH=$PATH:/usr/local/mysql/bin” >> /etc/profile
./etc/profile 生效
若出現(xiàn)FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
Data::Dumper
解決方法:yum –y install autoconf
5 添加系統(tǒng)服務(wù)
Cp support-files/mysql.server /usr/local/mysql/bin/mysql.sh
Chmod +x /usr/local/mysql/bin/mysql.sh
方法一:ln -s /usr/local/mysql/bin/* /usr/local/bin/ 用mysql.sh start 啟用
方法二:vim /usr/lib/systemd/system/mysqld.service
重新加載:systemctl daemon-reload 重啟
systemctl stop(start) mysqld
三 構(gòu)建PHP運(yùn)行環(huán)境
1.查看并卸載rpm包PHP
rpm -e php php-cli php-ldap php-common php-mysql --nodeps
2.安裝mcrypt加密工具
前提:yum -y install zlib-devel xz-devel libxml2-devel
(1)解壓
Libmcrypt mhash mcrypt (可以從http://sourceforge.net下載)
(2)cd /usr/src/libmcypt...
./configure && make && make install
ln -s /usr/local/lib/libmcrypt. /usr/lib
(3)cd /usr/src/mhash...
./configure && make && make install
ln -s /usr/local/lib/libmhash /usr/lib
(4)cd /usr/src/mcrypt...
./configure && make && make install
若報(bào)錯(cuò)(configure: error: *** libmcrypt was not found),
則export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH后重新配置安裝
3.編譯安裝PHP
(1)解壓: tar zxf php-5... -C /usr/src
(2)編譯安裝
cd /usr/src/php-5...
./configure --prefix=/usr/local/php5 --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php5 --enable-mbstring && make && make install
4.設(shè)置LAMP組建環(huán)境
(1)php.ini配置調(diào)整
安裝好PHP軟件包后,服務(wù)器并不會(huì)自動(dòng)創(chuàng)建php.ini的配置文件,但在源碼包目錄下提供兩個(gè)樣例
php.ini-development 開(kāi)發(fā)版
php.ini-production 生產(chǎn)版
cp /usr/src/php…/php.ini-development /usr/local/php5/php.ini
vim /usr/local/php5/php.ini
default_charset = "utf-8"
short_open_tag = on
extension=php_mysqli.dll
(2)添加ZendGuardLoader優(yōu)化模塊(http://www.zend.com)
tar zxf zend... -C /usr/src
cd /usr/src/zend...
cp Zend... /usr/local/php5/lib/php
vim /usr/loca/php5/php.ini
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
(3)httpd.conf配置調(diào)整
vim /usr/local/httpd/conf/httpd.conf
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php
/usr/local/httpd/bin/apachectl restart
(4)測(cè)試
①測(cè)試PHP網(wǎng)頁(yè)能否正確顯示
vim /usr/local/httpd/htdocs/test1.php
<?php
phpinfo();
?>
結(jié)果:
②測(cè)試PHP網(wǎng)頁(yè)能否訪問(wèn)MySQL數(shù)據(jù)庫(kù)
vim /usr/local/httpd/htdocs/test2.php
結(jié)果:
5.安裝phpMyadmin(官方地址:http://www.phpadmin.net)
(1)解壓
(2)mv phpMyadmin... /usr/local/httpd/htdocs/phpmyadmin
(3)cd /usr/local/httpd/htdocs/phpmyadmin
cp config.sample.inc.php config.inc.php
(4)訪問(wèn)測(cè)試
mysqladmin -u root -p password ‘123456’
結(jié)果:
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。