以root目錄爲例:php
cd ~ # 下載安裝包 wget http://nginx.org/download/nginx-1.17.2.tar.gz # nginx wget https://www.php.net/distributions/php-7.3.7.tar.gz # php
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar # mysql
# 解壓
tar zxvf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar
tar zxvf php-7.3.7.tar.gz
tar zxvf nginx-1.17.2.tar.gz
# 安裝cmakehtml
yum install -y gcc gcc-c++ make automake
# 下載 cmake
wget https://github.com/Kitware/CMake/releases/download/v3.15.1/cmake-3.15.1.tar.gz
tar zxvf cmake-3.15.1.tar.gz
cd cmake-3.15.1
./configure --prefix=/usr/local/cmake
make && make install
建立 cmake的軟鏈接
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
# 卸載自帶的 Mariadb
rpm -qa|grep mariadb # 查看當前系統自帶的Mariadb
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
# 建立用戶組node
groupadd mysql
# 建立mysql用戶,屬於mysql組mysql
useradd -g mysql mysql
# 安裝nginx
# 安裝依賴 yum install -y libaio rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm --nodeps --force # 安裝common rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm --nodeps --force # 安裝libs rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm --nodeps --force # 安裝client rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm --nodeps --force #安裝server # 修改組 chown mysql:mysql /var/lib/mysql -R # 啓動 systemctl start mysqld.service # 開機自啓 systemctl enable mysqld
# 查看默認密碼
cat /var/log/mysqld.log | grep password # 修改密碼 alter user 'root'@'localhost' identified by '123456';
# 安裝依賴c++
yum install screen gcc git openssl curl yum install gmp-devel libc-client-devel bzip2-devel enchant-devel libwebp-devel libXpm-devel openldap openldap-devel php-pspell aspell-devel readline-devel libtidy-devel libxslt-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel autoconf
若是 提示Please reinstall the libzip distribution
git
# 先卸載原先的 libzip
yum remove libzip
# 下載 libzip 源碼(去網站選擇合適的版本)
wget https://libzip.org/download/libzip-1.5.1.tar.gz
# 解壓
tar -zxvf libzip-1.5.1.tar.gz
cd libzip--1.5.1
# 配置
./configure
# 編譯 & 安裝
make & make install
# 編譯安裝github
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/conf.d --with-sqlite3 --with-pdo-sqlite --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-posix --enable-pcntl --enable-shmop --enable-sysvshm --enable-sysvsem --enable-sysvmsg --enable-phar --enable-zip --with-zlib --with-zlib-dir --with-bz2 --with-gd --enable-gd-jis-conv --with-webp-dir --with-jpeg-dir --with-png-dir --with-xpm-dir --with-freetype-dir --enable-exif --enable-json --enable-libxml --with-libxml-dir --enable-xml --enable-xmlreader --enable-xmlwriter --enable-simplexml --with-pear --with-xsl --enable-dom --enable-soap --enable-wddx --with-xmlrpc --enable-ctype --enable-filter --with-pcre-regex --with-pcre-jit --with-enchant --with-pspell --enable-fileinfo --enable-mbstring --with-iconv --enable-hash --with-openssl --enable-bcmath --with-gmp --enable-session --enable-sockets --enable-ftp --with-curl --with-ldap --with-ldap-sasl --with-imap --with-kerberos --with-imap-ssl --enable-calendar --with-gettext --with-tidy --with-readline --enable-tokenizer --enable-opcache --enable-cli --enable-cgi --enable-fpm --enable-phpdbg # 提示 libc-client 和 libldap 問題 從新./configure ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so cp -frp /usr/lib64/libldap* /usr/lib/ # 編譯 collect2: error: ld returned 1 exit status 在PHP源碼目錄下 vi Makefile 找到 EXTRA_LIBS 行,在行末添加 ‘ -llber ‘ 保存退出再次make便可 # 安裝 make -j `grep processor /proc/cpuinfo | wc -l` && make install
# 拷貝配置文件web
cp php.ini-production /usr/local/php/etc/php.ini cd /usr/local/php/etc/ cp php-fpm.conf.default ./php-fpm.conf cd php-fpm.d/ cp www.conf.default www.conf
# 啓動php-fpm,nginx須要將.php文件交給php-fpm處理sql
/usr/loca/php/sbin/php-fpm
cd ~/nginx-1.17.2 ./configure --prefix=/usr/local/nginx make && make install
# 啓動
cd /usr/local/nginx/
# 查看是否成功安裝
curl 127.0.0.1 # 有welcome nginx即成功
# 修改配置
vim ./conf/nginx.conf # 修改以下
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name; include fastcgi_params; }
# 重啓
./sbin/nginx -s reload
安裝完畢!