新聞中心
簡介
LAMP指Linux+apache+mysql/MariaDB+Perl/php/Python是一組常用來搭建動態(tài)網(wǎng)站或者服務(wù)器的開源軟件,本身都是各自獨(dú)立的程序,但是因?yàn)槌1环旁谝黄鹗褂?,擁有了越來越高的兼容度,共同組成了一個(gè)強(qiáng)大的Web應(yīng)用程序平臺。

成都創(chuàng)新互聯(lián)專注于屏邊企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站建設(shè),購物商城網(wǎng)站建設(shè)。屏邊網(wǎng)站建設(shè)公司,為屏邊等地區(qū)提供建站服務(wù)。全流程按需搭建網(wǎng)站,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,成都創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
部署方式
手動部署
系統(tǒng)平臺:centos 7.2
Apache版本:2.4.23
Mysql 版本:5.7.17
Php版本:7.0.12
安裝前準(zhǔn)備
關(guān)閉防火墻:
systemctl stop firewalld.service
關(guān)閉防火墻開機(jī)自啟動:
systemctl disable firewalld.service
安裝vim及unzip:
yum install -y vim unzip
編譯安裝apache準(zhǔn)備
編譯安裝apache前需要安裝apr、apr-util和pcre軟件包和相關(guān)依賴包。
yum install -y gcc gcc-c++ autoconf libtool
安裝apr
cd /usr/local/src/wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-1.5.0.tar.gztar zxvf apr-1.5.0.tar.gzcd apr-1.5.0./configure --prefix=/usr/local/aprmake && make install
安裝apr-util
cd /usr/local/src/wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-util-1.5.3.tar.gztar zxvf apr-util-1.5.3.tar.gzcd apr-util-1.5.3./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprmake && make install
安裝pcre
cd /usr/local/src/wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/pcre/pcre-8.38.tar.gztar zxvf pcre-8.38.tar.gzcd pcre-8.38./configure --prefix=/usr/local/pcremake && make install
編譯安裝Apache
cd /usr/local/src/wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/apache/httpd-2.4.23.tar.gztar zxvf httpd-2.4.23.tar.gzcd httpd-2.4.23./configure \--prefix=/usr/local/apache --sysconfdir=/etc/httpd \--enable-so --enable-cgi --enable-rewrite \--with-zlib --with-pcre=/usr/local/pcre \--with-apr=/usr/local/apr \--with-apr-util=/usr/local/apr-util \--enable-mods-shared=most --enable-mpms-shared=all \--with-mpm=eventmake && make install
修改httpd.conf配置文件參數(shù)
cd /etc/httpd/vim httpd.conf
1.找到Directory參數(shù),注釋掉Require all denied添加Require all granted。
2.找到ServerName參數(shù),添加ServerName localhost:80 然后,按Esc鍵后輸入:wq保存退出。
設(shè)置PidFile路徑
vim /etc/httpd/httpd.conf
在配置文件最后添加以下內(nèi)容:
PidFile"/var/run/httpd.pid"
啟動Apache服務(wù)并驗(yàn)證
cd /usr/local/apache/bin/./apachectl startnetstat -tnlp #查看服務(wù)是否開啟
在本地瀏覽器中輸入云服務(wù)器的公網(wǎng)IP地址驗(yàn)證,出現(xiàn)下圖表示安裝成功。
設(shè)置開機(jī)自啟
在rc.local文件中添加/usr/local/apache/bin/apachectl start,然后輸入:wq保存退出。
vim /etc/rc.d/rc.local
設(shè)置環(huán)境變量
vi /root/.bash_profile
在PATH=$PATH:$HOME/bin添加參數(shù)為:
PATH=$PATH:$HOME/bin:/usr/local/apache/bin
然后輸入:wq保存退出,執(zhí)行:
source /root/.bash_profile
編譯安裝MySQL前預(yù)準(zhǔn)備
首先檢查系統(tǒng)中是否存在使用rpm安裝的mysql或者mariadb,如果有需要先刪除后再編譯安裝。
rpm -qa | grep mysql #由下至上依次卸載rpm -qa | grep mariadbrpm -e xxx #一般使用此命令即可卸載成功rpm -e --nodeps xxx #卸載不成功時(shí)使用此命令強(qiáng)制卸載
卸載完以后用 rpm -qa|grep mariadb 或者 rpm -qa|grep mysql 查看結(jié)果。
安裝mysql
yum install -y libaio-*#安裝依賴mkdir -p /usr/local/mysqlcd /usr/local/srcwget http://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gztar -xzvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gzmv mysql-5.7.17-linux-glibc2.5-x86_64/* /usr/local/mysql/
建立mysql組和用戶,并將mysql用戶添加到mysql組
groupadd mysqluseradd -g mysql -s /sbin/nologin mysql
初始化mysql數(shù)據(jù)庫
/usr/local/mysql/bin/mysqld --initialize-insecure --datadir=/usr/local/mysql/data/--user=mysql
更改mysql安裝目錄的屬主屬組
chown -R mysql:mysql /usr/local/mysqlchown -R mysql:mysql /usr/local/mysql/data/chown -R mysql:mysql /usr/local/mysql
設(shè)置開機(jī)自啟
cd /usr/local/mysql/support-files/cp mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqld # 添加執(zhí)行權(quán)限vim /etc/rc.d/rc.local
添加/etc/init.d/mysqld start到rc.local文件中,然后輸入:wq保存退出。
設(shè)置環(huán)境變量
vi /root/.bash_profile
在PATH=$PATH:$HOME/bin添加參數(shù)為:
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
然后輸入:wq保存退出,輸入:
source /root/.bash_profile
啟動MySQL數(shù)據(jù)庫
/etc/init.d/mysqld start
修改Mysql的root用戶密碼
初始化后mysql為空密碼可直接登錄,為了保證安全性需要修改mysql的root用戶密碼。
mysqladmin -u root password 'xxxx'
測試登錄MySQL數(shù)據(jù)庫
mysql -uroot -p密碼#-p和密碼之間無空格
編譯安裝php
依賴安裝:
yum install php-mcrypt libmcrypt libmcrypt-devel libxml2-devel openssl-devel libcurl-devel libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 libjpeg-turbo-devel libmcrypt-devel mysql-devel -ywget http://zy-res.oss-cn-hangzhou.aliyuncs.com/php/php-7.0.12.tar.gztar zxvf php-7.0.12.tar.gzcd php-7.0.12./configure \--prefix=/usr/local/php \--with-mysql=mysqlnd --with-openssl \--with-mysqli=mysqlnd \--enable-mbstring \--with-freetype-dir \--with-jpeg-dir \--with-png-dir \--with-zlib --with-libxml-dir=/usr \--enable-xml --enable-sockets \--with-apxs2=/usr/local/apache/bin/apxs \--with-mcrypt --with-config-file-path=/etc \--with-config-file-scan-dir=/etc/php.d \--enable-maintainer-zts \--disable-fileinfomake && make install
復(fù)制配置文件
cd php-7.0.12cp php.ini-production /etc/php.ini
編輯apache配置文件httpd.conf,以apache支持php
vim /etc/httpd/httpd.conf
在配置文件最后添加如下二行:
AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps
定位到 DirectoryIndex index.html
修改為:
DirectoryIndex index.php index.html
重啟apache服務(wù)
/usr/local/apache/bin/apachectl restart
測試是否能夠正常解析PHP
cd /usr/local/apache/htdocs/vim index.php #添加如下內(nèi)容phpinfo();?>
訪問云服務(wù)器的公網(wǎng)IP/index.php,出現(xiàn)如下頁面表示解析成功。
安裝phpmyadmin
mkdir -p /usr/local/apache/htdocs/phpmyadmincd /usr/local/src/wget http://oss.aliyuncs.com/aliyunecs/onekey/phpMyAdmin-4.1.8-all-languages.zipunzip phpMyAdmin-4.1.8-all-languages.zipmv phpMyAdmin-4.1.8-all-languages/* /usr/local/apache/htdocs/phpmyadmin
下面關(guān)于LAMP相關(guān)的內(nèi)容你可能也喜歡:
網(wǎng)站題目:CentOS7.2下安裝部署LAMP詳解
文章出自:http://m.fisionsoft.com.cn/article/cdsscpe.html


咨詢
建站咨詢
