溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

LAMP平臺(tái)部署與應(yīng)用

發(fā)布時(shí)間:2020-06-29 12:46:23 來(lái)源:網(wǎng)絡(luò) 閱讀:348 作者:zw773860471 欄目:MySQL數(shù)據(jù)庫(kù)

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é)果如圖:
LAMP平臺(tái)部署與應(yīng)用
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
LAMP平臺(tái)部署與應(yīng)用
添加系統(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
LAMP平臺(tái)部署與應(yīng)用
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é)果如圖:
LAMP平臺(tái)部署與應(yīng)用

Vim /usr/local/httpd/conf/httpd.conf
LAMP平臺(tái)部署與應(yīng)用

二 安裝啟動(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/
LAMP平臺(tái)部署與應(yīng)用
設(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
LAMP平臺(tái)部署與應(yīng)用
重新加載: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"
LAMP平臺(tái)部署與應(yīng)用
short_open_tag = on
LAMP平臺(tái)部署與應(yīng)用
extension=php_mysqli.dll
LAMP平臺(tái)部署與應(yīng)用
(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
LAMP平臺(tái)部署與應(yīng)用
(3)httpd.conf配置調(diào)整
vim /usr/local/httpd/conf/httpd.conf
DirectoryIndex index.html index.php
LAMP平臺(tái)部署與應(yīng)用
AddType application/x-httpd-php .php
LAMP平臺(tái)部署與應(yīng)用
/usr/local/httpd/bin/apachectl restart
(4)測(cè)試
①測(cè)試PHP網(wǎng)頁(yè)能否正確顯示
vim /usr/local/httpd/htdocs/test1.php
<?php
phpinfo();
?>
LAMP平臺(tái)部署與應(yīng)用
結(jié)果:
LAMP平臺(tái)部署與應(yīng)用
②測(cè)試PHP網(wǎng)頁(yè)能否訪問(wèn)MySQL數(shù)據(jù)庫(kù)
vim /usr/local/httpd/htdocs/test2.php
LAMP平臺(tái)部署與應(yīng)用
結(jié)果:
LAMP平臺(tái)部署與應(yīng)用
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é)果:
LAMP平臺(tái)部署與應(yīng)用

向AI問(wèn)一下細(xì)節(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)容。

AI