編譯配置LAMP
阿新 • • 發佈:2018-07-19
root用戶 net grant red bin host default 5.7 src
編譯安裝Apache
1、安裝一些apache的依賴包
yum install -y gcc gcc-c++ autoconf libtool
2、安裝apr
(1) cd /usr/local/src/
(2) wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-1.5.0.tar.gz
(3) tar zxvf apr-1.5.0.tar.gz
(4) cd apr-1.5.0
(5) ./configure --prefix=/usr/local/apr
(6) make && make install
3、安裝apr-util
(1) cd /usr/local/src/ (2) wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-util-1.5.3.tar.gz (3) tar zxvf apr-util-1.5.3.tar.gz (4) cd apr-util-1.5.3 (5) ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr (6) make && make install
4、安裝pcre
(1) cd /usr/local/src/
(2) wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/pcre/pcre-8.38.tar.gz
(3) tar zxvf pcre-8.38.tar.gz
(4) cd pcre-8.38
(5) ./configure --prefix=/usr/local/pcre
(6) make && make install
5、安裝apache
(1) make && make install (2) wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/apache/httpd-2.4.23.tar.gz (3) tar zxvf httpd-2.4.23.tar.gz (4) cd httpd-2.4.23 (5) ./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=event
(6) make && make install
6、修改httpd.conf配置文件
(1) cd /etc/httpd/
(2) vim httpd.conf
a 找到Directory參數,註釋掉Require all denied添加Require all granted。
b 找到ServerName參數,添加ServerName localhost:80 然後,按Esc鍵後輸入:wq保存退出。
c 在配置文件中添加 PidFile "/var/run/httpd.pid"
7、啟動Apache服務
(1) cd /usr/local/apache/bin/ (2) ./apachectl start (3) netstat -tnlp
8、設置開機自啟
在/etc/rc.d/rc.local文件中添加apache啟動命令
(1) vim /etc/rc.d/rc.local 將/usr/local/apache/bin/apachectl start 寫入文件
(2) 設置環境變量
a vim /root/.bash_profile 將 PATH=$PATH:$HOME/bin:/usr/local/apache/bin 寫入
b source /root/.bash_profile
編譯安裝MySQL
1、檢查系統中是否有MySQL,若有先刪除在安裝
(1) rpm -qa | grep mysql
(2) rpm -qa | grep mariadb
(3) rpm -e xxx #卸載
(4) rpm -e --nodeps xxx #強制卸載
2、安裝MySQL
(1) yum install -y libaio-* #安裝mysql所需要的依賴包
(2) mkdir -p /usr/local/mysql
(3) cd /usr/local/src
(4) wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
(5) tar -xzvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
(6) mv mysql-5.7.17-linux-glibc2.5-x86_64/* /usr/local/mysql/
3、建立mysql組和用戶,並將mysql用戶添加到mysql組中
(1) groupadd mysql
(2) useradd -g mysql -s /sbin/nologin mysql
4、初始化
/usr/local/mysql/bin/mysqld --initialize-insecure --datadir=/usr/local/mysql/data/ --user=mysql
5、更改mysql安裝目錄的屬組
(1) chown -R mysql:mysql /usr/local/mysql
(2) chown -R mysql:mysql /usr/local/mysql/data/
(3) chown -R mysql:mysql /usr/local/mysql
6、設置開機自啟
(1) cd /usr/local/mysql/support-files/
(2) cp mysql.server /etc/init.d/mysqld
(3) chmod +x /etc/init.d/mysqld
(4) vim /etc/rc.d/rc.local 將/etc/init.d/mysqld start添加到rc.local文件
7、設置環境變量
(1) vim /root/.bash_profile 將PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib寫入文件
(2) source /root/.bash_profile
8、啟動mysql
/etc/init.d/mysql start
9、修改mysql的root用戶密碼
mysqladmin -u root password ‘12345678‘
10、添加my.cnf文件
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
編譯安裝PHP
編輯配置文件,是Apache支持PHP
1、在httpd.conf中寫入相應的配置
(1) vim /etc/httpd/httpd.conf 在配置文件中添加下面配置
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
(2) 將httpd.conf中的 DirectoryIndex index.html 改為 DirectoryIndex index.php index.html
2、重啟apache
/usr/local/apache/bin/apachectl restart
編譯配置LAMP