前言:yum安裝好是好狰贯,方便是方便但是內(nèi)部相關(guān)的依賴是不好找也搓,因此要想變成大神那么就要從源碼編譯安裝赏廓,而且源碼安裝還能減少不必要的錯(cuò)誤
前期準(zhǔn)備
- 將防火墻與selinux關(guān)閉
- http://httpd.apache.org/download.cgi //http壓縮包
- http://apr.apache.org/download.cgi //http插件包這里要注意安裝相同版本的如1.6對(duì)應(yīng)也要1.6
- http://mirrors.sohu.com/mysql/ //mysql壓縮包
- http://www.php.net/downloads.php //PHP壓縮包
安裝httpd(apache)服務(wù)
- yum -y install gcc gcc-c++ make pcre-devel expat-devel perl
- tar xf apr-1.6.2.tar.gz
- tar xf apr-util-1.6.0.tar.gz
- tar xf httpd-2.4.29.tar.bz2
- mv apr-1.6.2 httpd-2.4.29/srclib/apr
- mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
- cd httpd-2.4.29
- ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
- make && make install
- cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
- vi /etc/init.d/httpd
- chkconfig --add httpd //將httpd加入到SERVICE管理器
- systemctl daemon-reload //重載系統(tǒng)系統(tǒng)管理器
- vi /usr/local/httpd/conf/httpd.conf
修改 ServerName www.test.com - ln -s /usr/local/httpd/conf/httpd.conf /etc/
- ln -s /usr/local/httpd/bin/* /usr/local/bin/
- httpd –t
- systemctl start httpd
- systemctl enable httpd
- netstat -anpt | grep 80
訪問centos返回it workw代表成功
安裝mysql
- yum -y install ncurses ncurses-devel bison cmake
- useradd -s /sbin/nologin mysql
- tar xf mysql-boost-5.7.20.tar.gz -C /opt/
- cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ //定義安裝目錄
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ //連接數(shù)據(jù)庫(kù)socket路徑
-DSYSCONFDIR=/etc \ //指定初始化參數(shù)文件目錄(my.cnf)
-DSYSTEMD_PID_DIR=/usr/local/mysql \ //數(shù)據(jù)庫(kù)目錄
-DDEFAULT_CHARSET=utf8 \ //指定默認(rèn)使用的字符集編碼
-DDEFAULT_COLLATION=utf8_general_ci \ //指定默認(rèn)使用的字符集校對(duì)規(guī)則,utf8_general_ci是適用于UTF-8字符集的通用規(guī)則
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ //支持InnoDB引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \ //安裝支持?jǐn)?shù)據(jù)庫(kù)分區(qū)
-DMYSQL_DATADIR=/usr/local/mysql/data
-DWITH_BOOST=boost
-DWITH_SYSTEMD=1
記得把中文去了不然不知道會(huì)報(bào)什么錯(cuò)傍妒,(注意:如果在CMAKE的過程中有報(bào)錯(cuò)幔摸,當(dāng)報(bào)錯(cuò)解決后,需要把源碼目錄中的CMakeCache.txt文件刪除颤练,然后再重新CMAKE既忆,否則錯(cuò)誤依舊)
- make && make install
- chown -R mysql.mysql /usr/local/mysql/
- vi /etc/my.cnf
(里面內(nèi)容全部刪除,替換成以下內(nèi)容)
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
chown mysql:mysql /etc/my.cnf
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
//把這兩個(gè)路徑添加到環(huán)境變量中嗦玖,并放到profile文件中使之開機(jī)自運(yùn)行患雇,否則不生效echo 'export PATH' >> /etc/profile
source /etc/profile //立即生效
cd /usr/local/mysql/
bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl start mysqld
netstat -anpt | grep 3306 //查看服務(wù)運(yùn)行狀態(tài)
systemctl enable mysqld //設(shè)為開機(jī)啟動(dòng)
mysqladmin -u root -p password "abc123"
//給root賬號(hào)設(shè)置密碼為abc123
注意:提示輸入的是原始密碼(原始沒有密碼,直接回車)mysql -u root –p //登錄數(shù)據(jù)庫(kù)
注意:有密碼的加“-p”,如果沒有密碼不用加“-p”
搭建PHP運(yùn)行環(huán)境
https://www.cnblogs.com/chenppp/p/13388748.html //php7.4安裝方法
https://www.cnblogs.com/chenppp/p/13276602.html //nginx1.18安裝方法
https://www.cnblogs.com/ansibee/p/8087476.html //安裝完成后需要添加服務(wù)才可以
可能會(huì)報(bào)錯(cuò):oniguruma包報(bào)錯(cuò) 加上編譯參數(shù): --with-libdir=lib64https://www.cnblogs.com/cndavidwang/p/12343847.html
https://blog.csdn.net/gshzh00/article/details/90901121 //開機(jī)自啟動(dòng)nginx
http://www.reibang.com/p/33b44a14ebf7 //開啟自啟動(dòng)php-fpm
https://segmentfault.com/a/1190000018849299 //php7.2教程
- 執(zhí)行nginx所在安裝目錄并啟動(dòng) /usr/local/nginx/sbin/nginx
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel
(注意:如果安裝過程出錯(cuò)宇挫,修改下面文件苛吱,添加一行)
vi /usr/local/httpd/bin/apxs
#!/usr/bin/perl –w
- tar xjvf php-7.1.10.tar.bz2
- cd php-7.1.10
- ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql-sock=/usr/local/mysql/mysql.sock --with-mysqli --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-mbstring --enable-xml --enable-session --enable-ftp --enable-pdo --enable-tokenizer --enable-zip
- make && make install
- cp php.ini-development /usr/local/php/lib/php.ini
- vi /usr/local/php/lib/php.ini //編輯配置文件
mysqli.default_socket = /usr/local/mysql/mysql.sock //將php與mysql關(guān)聯(lián)
date.timezone = Asia/Shanghai //時(shí)區(qū)設(shè)置
/usr/local/php/bin/php –m //驗(yàn)證安裝的模塊 - vi /etc/httpd.conf //編輯Apache配置文件,使httpd支持php網(wǎng)頁(yè)解析
添加以下兩行內(nèi)容:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
修改以下內(nèi)容:
DirectoryIndex index.php index.html //此處注意器瘪,php文件必須放前面翠储,優(yōu)先讀取 - rm -f /usr/local/httpd/htdocs/index.html //刪除默認(rèn)html文件
- vi /usr/local/httpd/htdocs/index.php //編輯php測(cè)試網(wǎng)頁(yè)
添加以下內(nèi)容(php信息)
<?php
phpinfo();
?> - systemctl start httpd //重啟httpd服務(wù)
- 常用的編譯參數(shù)
--help獲取./configure腳本幫助
--prefix=: 指定安裝路徑;多數(shù)程序都有默認(rèn)安裝路徑橡疼;
--sysconfidr=: 指定配置文件安裝路徑援所;
--with-PACKAGE[=ARG]:在自由軟件社區(qū)里,有使用已有軟件包和庫(kù)的優(yōu)秀傳統(tǒng).當(dāng)用'configure'來(lái)配置一個(gè)源碼樹時(shí),
可以提供其他已經(jīng)安裝的軟件包的信息
--without-PACKAGE:有時(shí)候你可能不想讓你的軟件包與系統(tǒng)已有的軟件包交互。例如欣除,你可能不想讓你的新編譯器使用
GNU ld
--enable-FEATURE:一些軟件包可能提供了一些默認(rèn)被禁止的特性,可以使用'--enable-FEATURE'來(lái)起用它
--disable-EEATURE:關(guān)閉指定的默認(rèn)特性
1. 安裝成功后配置環(huán)境變量
打開: /etc/profile 尾部添加
PATH=$PATH:/usr/local/php-7.2.19/bin
export PATH
2. 保存后刷新環(huán)境變量
source /etc/profile #更新
3.查看環(huán)境變量:
echo $PATH
4.看到php環(huán)境變量的路徑后住拭,以后就可以直接使用php命令了,查看php版本
php -v
6.現(xiàn)在的PHP沒有.ini文件和配置文件,還需要配置PHP-FPM:
cp php.ini-production /etc/php.ini
cp /usr/local/php-7.2.19/etc/php-fpm.conf.default /usr/local/php-7.2.19/etc/php-fpm.conf
cp /usr/local/php-7.2.19/etc/php-fpm.d/www.conf.default /usr/local/php-7.2.19/etc/php-fpm.d/www.conf
cp /usr/localsoft/php-7.2.19/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
7.php-fpm的啟動(dòng)历帚、停止和重啟
service php-fpm start #啟動(dòng)
service php-fpm stop #停止
service php-fpm restart #重啟
apache下配置多站點(diǎn)
https://blog.csdn.net/qq_27229113/article/details/81252253 //轉(zhuǎn)載他人項(xiàng)目
配置git倉(cāng)庫(kù)及安裝git
- yum remove git //卸載yum源安裝的git
- make configure //解壓并進(jìn)入文件滔岳,執(zhí)行
- ./configure --prefix=/usr/local/git //指定安裝目錄
- make profix=/usr/local/git //編譯
- make install //安裝
- echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile //修改環(huán)境變量
- source /etc/profile //重啟環(huán)境變量
- git --version //查看當(dāng)前版本
參考1:https://blog.51cto.com/13043516/2152749
參考2:https://www.cnblogs.com/dee0912/p/5815267.html
參考3:http://www.reibang.com/p/2dbe08bc8d40
*參考4:https://www.linuxidc.com/Linux/2018-03/151133.htm
編譯安裝swoole
1.官網(wǎng)下載
-
https://gitee.com/swoole/swoole
2.生成configure,注意要裝autoconfig否則無(wú)法生成(yum -y install autoconf) - /usr/local/php-7.2.19/bin/phpize //php工具生成前面是你安裝路徑
- ./configure --with-php-config=/usr/local/php-7.2.19/bin/php-config
- make && make install
- php.ini 引入swool.so文件
編譯安裝git
*解壓后可能會(huì)缺少configure 執(zhí)行autoconf
*可能還會(huì)缺少zlib.h: No such file or directory //yum install zlib-devel
- ./configure --prefix=/usr/local/git
- make && make install
*修改環(huán)境變量
vi ~/.bash_profile
PATH=$PATH:/home/git
php7安裝phpredis
https://blog.csdn.net/guo_qiangqiang/article/details/103178556