沒有開頭語。php
操做系統:CentOs7.6 64位。node
Nginx:系統自帶 nginx1.12.2包。mysql
Mysql:系統自帶 MariaDB 5.6 ,更換爲 Mysql5.6nginx
PHP:系統php5.6包,更換爲7.2c++
軟件包:https://pan.baidu.com/s/1Gb4iz5mqLqNVWvvZdBiOMQ 提取碼: xrhx sql
把軟件包放在/usr/src文件夾下apache
首先更新一下系統自帶包,安裝依賴vim
yum update
yum install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel gd gd-devle libxml2 libxml2-devel curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype-devel apr apr-util
1、安裝nginxsession
下載源碼包並解壓php7
cd /usr/local/src wget http://nginx.org/download/nginx-1.12.2.tar.gz tar -zxvf nginx-1.12.2.tar.gz
進入目錄
cd nginx-1.12.2
編譯安裝 ,由於上邊yum安裝了二進制的openssl zlib 和pcre ,因此configure 配置 --with-pcre等就不用指定目錄了
./configure \ --prefix=/usr/local/nginx/ \ --user=www \ --group=www \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_sub_module \ --with-http_realip_module \ --with-http_image_filter_module \
make && make install
修改nginx.conf
cd /usr/local/nginx/conf/
cp nginx.conf nginx.conf.bak
vim nginx.conf
配置nginx 腳本控制
vim /etc/init.d/nginx
代碼是複製的,路徑須要根據本身的改一下
#!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: /usr/local/nginx/conf/nginx.conf # pidfile: /usr/local/nginx/logs/nginx.pid # Source function library. . /etc/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/local/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() { # make required directories user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -` if [ -z "`grep $user /etc/passwd`" ]; then useradd -M -s /bin/nologin $user fi options=`$nginx -V 2>&1 | grep 'configure arguments:'` for opt in $options; do if [ `echo $opt | grep '.*-temp-path'` ]; then value=`echo $opt | cut -d "=" -f 2` if [ ! -d "$value" ]; then # echo "creating" $value mkdir -p $value && chown -R $user $value fi fi done } start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 make_dirs echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { #configtest || return $? stop sleep 1 start } reload() { #configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac
設置腳本權限,設置開啓啓動,啓動nginx
chmod 775 /etc/rc.d/init.d/nginx chkconfig nginx on /etc/rc.d/init.d/nginx start
添加nginx到系統變量
echo 'export PATH=$PATH:/usr/local/nginx/sbin'>>/etc/profile && source /etc/profile
2、安裝Apache
apache安裝須要依賴pcre ,apr 和apr-util ,上邊已經安裝了二進制文件
下載源碼包並進入
cd /usr/local/src wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.38.tar.gz cd httpd-2.4.38
配置
./configure --prefix=/usr/local/apache \ --sysconfdir=/usr/local/apache/conf \ --enable-so \ --enable-rewrite \ --with-pcre
編譯安裝
make && make install
複製腳本、修改權限
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
cd /etc/init.d/ chmod 755 httpd
添加兩行內容到htppd,添加在第二三行便可
vim httpd
# chkconfig: 2345 70 30 # description: Apache
其中,所增長的第二行中三個數字,第一個表示在運行級別2345下啓動Apache,第2、三是關於啓動和中止的優先級配置。
設置開機啓動
chkconfig httpd on
加入環境變量
echo 'export PATH=$PATH:/usr/local/apache/bin'>>/etc/profile && source /etc/profile
啓動apache (由於nginx開啓後,80端口被佔用,此處須要關閉nginx服務,或者修改apache端口爲8080,而後重啓apache服務)
./httpd start
3、卸載MariaDB安裝Mysql
1.查看當前安裝列表
rpm -qa | grep mariadb
2.卸載mariadb
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
檢查有沒有卸載乾淨
rpm -qa | grep mariadb
3.安裝mysql5.6
下載mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
安裝mysql-community-release-el7-5.noarch.rpm包
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
安裝完這個包後,會得到兩個mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。
安裝mysql
sudo yum install mysql-server
4.配置開機啓動
systemctl enable mysqld
5.啓動mysql
systemctl start mysqld
6.重置密碼
7.受權遠程登陸
mysql -u root -p
use mysql;
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
刷新權限
flush privileges;
exit;
4、安裝php7.2
groupadd -r www && useradd -r -g www -s /bin/false -d /usr/local/php -M php
cd /usr/src tar -zxvf php-7.2.0.tar.gz
cd php-7.2.0
編譯安裝
./configure \ --prefix=/usr/local/php \ --exec-prefix=/usr/local/php \ --bindir=/usr/local/php/bin \ --sbindir=/usr/local/php/sbin \ --includedir=/usr/local/php/include \ --libdir=/usr/local/php/lib/php \ --mandir=/usr/local/php/php/man \ --with-config-file-path=/usr/local/php/etc \ --with-mysql-sock=/var/lib/mysql/mysql.sock \ --with-mhash \ --with-openssl \ --with-mysqli=shared,mysqlnd \ --with-pdo-mysql=shared,mysqlnd \ --with-gd \ --with-iconv \ --with-zlib \ --enable-zip \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-mbregex \ --enable-mbstring \ --enable-ftp \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --with-curl \ --with-jpeg-dir=/usr/lib \ --with-freetype-dir \ --enable-opcache \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --without-gdbm \ --with-apxs2=/usr/local/apache/bin/apxs make && make install
cp php.ini-development /usr/local/php/etc/php.ini cp php.ini-development /etc/php.ini cp /usr/local/php/sbin/php-fpm /etc/init.d/php-fpm cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
vim /usr/local/php/etc/php-fpm.conf
去掉 pid = run/php-fpm.pid 前面的‘;’
配置全局環境變量
vim /etc/profile
在最後一行加入
export PATH=$PATH:/usr/local/php/bin
刷新
source /etc/profile
執行 /etc/init.d/php-fpm