第十二章LNMP架構上預習筆記
12.1 LNMP架構介紹
12.2 MySQL安裝
下載二進位制免編譯包,並解壓
cd /usr/local/src
wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
tar xvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
安裝
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
更改配置檔案
拷貝啟動指令碼
cp support-files/mysql.server /etc/init.d/mysqld
更改啟動指令碼檔案,定義 basedir datadir
vim /etc/init.d/mysqld
新增到服務列表裡面,並設定為開機啟動
實驗中的報錯
之前安裝過mariadb,把服務killall
12.3 PHP安裝(上)
useradd -s /sbin/nologin php-fpm
wget http://cn2.php.net/distributions/php-5.6.32.tar.bz2
tar xvf php-5.6.32.tar.bz2
yum -y install libxml2-devel.x86_64,openssl-devel,curl-devel,libjpeg-devel,libpng-devel,freetype-devel,libmcrypt-devel,
./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
make && make install cp php.ini-production /usr/local/php-fpm/etc/php.ini
vim /usr/local/php-fpm/etc/php-fpm.conf
[global] pid = /usr/local/php-fpm/var/run/php-fpm.pid error_log = /usr/local/php-fpm/var/log/php-fpm.log [www] listen = /tmp/php-fcgi.sock listen.mode = 666 user = php-fpm group = php-fpm pm = dynamic pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500 rlimit_files = 1024
cd /usr/local/src/php-5.6.32
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
安裝時報的錯
12.4 PHP安裝(下)
12.5 Nginx介紹
12.6 Nginx安裝
cd /usr/local/src
tar xvf nginx-1.14.0.tar.gz
make && make install
檢查配置檔案是否有誤
編輯啟動指令碼
vim /etc/init.d/nginx
#!/bin/bash # chkconfig: - 30 21 # description: http service. # Source Function Library . /etc/init.d/functions # Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx" NGINX_CONF="/usr/local/nginx/conf/nginx.conf" NGINX_PID="/usr/local/nginx/logs/nginx.pid" RETVAL=0 prog="Nginx"
start() { echo -n $"Starting $prog: " mkdir -p /dev/shm/nginx_temp daemon $NGINX_SBIN -c $NGINX_CONF RETVAL=$? echo return $RETVAL }
stop() { echo -n $"Stopping $prog: " killproc -p $NGINX_PID $NGINX_SBIN -TERM rm -rf /dev/shm/nginx_temp RETVAL=$? echo return $RETVAL }
reload() { echo -n $"Reloading $prog: " killproc -p $NGINX_PID $NGINX_SBIN -HUP RETVAL=$? echo return $RETVAL }
restart() { stop start }
configtest() { $NGINX_SBIN -c $NGINX_CONF -t return 0 }
case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) restart ;; configtest) configtest ;; *) echo $"Usage: $0 {start|stop|reload|restart|configtest}" RETVAL=1 esac
exit $RETVAL
新增服務和開機啟動
啟動nginx 服務
測試php解析
vim /usr/local/nginx/html/1.php