網站製作-LAMP環境(分離部署)
阿新 • • 發佈:2020-12-01
此文轉載自:https://blog.csdn.net/m0_50744953/article/details/110350763#commentBox
LAMP
環境
- 兩臺Linux
- 1:apache+php(IP:192.168.1.1)
- 2:mysql(IP:192.168.1.2)
配置
- 首先安裝好apache
- 安裝PHP
- rpm -ivh zlib-devel-1.2.7-17.el7.x86_64.rpm
rpm -ivh xz-devel-5.2.2-1.el7.x86_64.rpm
rpm -ivh libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm - 拖進原始碼包
cd
tar -zxvf libmcrypt-2.5.8.tar.gz -C /usr/src/
cd /usr/src/libmcrypt-2.5.8/
./configure && make && make install
ln -s /usr/local/lib/libmcrypt.* /usr/lib/
- hash演算法
cd
tar -zxvf mhash-0.9.9.9.tar.gz -C /usr/src/
cd /usr/src/mhash-0.9.9.9/
./configure && make && make install
ln -s /usr/local/lib/libmhash* /usr/lib/
- 加密
cd
tar -zxvf mcrypt-2.6.8.tar.gz -C /usr/src/
cd /usr/src/mcrypt-2.6.8/
./configure
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
./configure
make && make install
- php
cd
tar -zxvf php-5.5.38.tar.gz -C /usr/src/
cd /usr/src/php-5.5.38/
./configure --prefix=/usr/local/php --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql --with-mysqli --with-config-file-path=/usr/local/php --enable- mbstring --enable-sockets
make && make install
cp /usr/src/php-5.5.38/php.ini-development /usr/local/php/php.ini
- 新增ZendGuardLoader優化模組:
tar -zxvf zend-loader-php5.5-linux-x86_64_update1.tar.gz -C /usr/src/
cd /usr/src/zend-loader-php5.5-linux-x86_64/
ls
cp ZendGuardLoader.so /usr/local/php/lib/php/
vim /usr/local/php/php.ini
修改:
default_charset = "utf-8”(不修改這個會亂碼)
新增:
zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so #模組路徑
zend_loader.enable=1 #開啟模組
vim /usr/local/httpd/conf/httpd.conf
改:LoadModule php5_module modules/libphp5.so(64行)
加:AddType application/x-httpd-php .php
第259行改
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
第385行
#AddType application/x-gzip .tgz
AddType application/x-httpd-php .php (新增)
驗證連線
驗證PHP與Apache連線
vim index.php
新增:
<?php
phpinfo( );
?>
訪問
firefox http://192.168.1.1/
驗證PHP與MySQL連線
mv index.php index.php_back
vim index.php
新增:如果分散式部署的話把localhost換成mysql主機ip,並且在mysql上對apache授權
<?php
$link=mysqli_connect('192.168.1.2','root','123.com');
if($link) echo "恭喜你,資料庫連線成功啦!!";
?>
注意:MySQL端需要授權
grant all on *.* to 'root'@'192.168.1.1' identified by '123.com';
訪問
[root@localhost htdocs]#firefox http://192.168.1.1/ &
安裝phpMyAdmin
[root@localhost ~]#tar -zxvf phpMyAdmin-4.7.2-all-languages.tar.gz -C /usr/src/
[root@localhost ~]#cd /usr/src/
[root@localhost ~]#cp -r phpMyAdmin-4.7.2-all-languages/ /usr/local/httpd/htdocs/phpMyAdmin(自己建立)
[root@localhost ~]#cd /usr/local/httpd/htdocs/phpMyAdmin
[root@localhost ~]#cp config.sample.inc.php config.inc.php
vim config.inc.php
修改:
$cfg[‘blowfish_secret’] = ‘a8b7c6d’;
配置檔案裡新增 建立使用者為’root’,設定密碼為’123.com’
訪問
[root@localhost ~]#firefox http://192.168.1.1/phpMyAdmin &
登入進去後就是mysql圖形化介面
天越黑,星星越亮,加油