技術(shù)文檔
我們以安裝nginx1.8+php7.2版本為例進行手動安裝,具體安裝流程如下:
一、Nginx安裝:
1、安裝相關(guān)依賴包
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl
yum -yinstallopenssl-devel pcre pcre-devel
2、下載nginx安裝包,也可以到nginx官網(wǎng)找到你想要安裝的版本進行下載
nginx官網(wǎng)下載:http://nginx.org/download/
1)進入目錄: cd /usr/local
2)下載文件: wget http://nginx.org/download/nginx-1.8.0.tar.gz
3)解壓文件: tar -zxvf nginx-1.8.0.tar.gz
4)進入解壓后目錄: cd nginx-1.8.0
5)執(zhí)行命令編譯安裝:
. /configure
make make install
3,安裝完成之后在/usr/local文件夾下面會多出一個nginx的文件夾
1)進入/usr/local/nginx 目錄下:
cd /usr/local/nginx
2)執(zhí)行 ./sbin/nginx #啟動nginx服務(wù)
4,將nginx 加入服務(wù)項
1)創(chuàng)建服務(wù)文件:
vi /usr/lib/systemd/system/nginx.service
寫入以下代碼:
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
:wq #保存退出
5,測試啟動服務(wù)
systemctl start nginx.service
6,查看是否啟動
ps -ef | grep nginx
7,設(shè)置開機自啟動
systemctl enable nginx.service
到此nginx安裝完成
二、安裝PHP
1,安裝依賴包:
yum install -y gcc gcc-c++ libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel freetype freetype-devel
2,進入到/usr/local目錄下,下載php安裝包:
cd /usr/local
wget http://tz1.php.net/distributions/php-7.2.10.tar.gz
也可以進入到php官網(wǎng)去下載:http://php.net/downloads.php
3,解壓
tar -zxvf php-7.2.10.tar.gz
4,進入解壓出來的php目錄
cd php
注:如果解壓出來的不是php目錄,可以改名,比如解壓出來的目錄為php-7.2 ,需要執(zhí)行mv php-7.2 php ,修改成php
5,編譯php:
編譯:
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql --enable-maintainer-zts -with-mcrypt=/usr/include --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --enable-ftp --enable-session --with-gettext --with-jpeg-dir --with-freetype-dir --enable-fastcgi --without-gdbm --disable-fileinfo
6,安裝php:
make make install
7,安裝完成后可以通過php -v 可看php是否安裝成功。
8,如果php -v 無法執(zhí)行,可以將php加入到環(huán)境變量:
編輯環(huán)境變量文件: vi /etc/profile
文件末尾加上 export PATH="/usr/local/php/bin:$PATH"
其中"/usr/local/php/bin"為你安裝的具體路徑,保存退出后,執(zhí)行以下更改即可,執(zhí)行命令:
source /etc/profile
這個時候我們再次執(zhí)行php -v 就可以看到所安裝的版本號了。
到此安裝完成。