yum install epel-release
複製代碼
yum install gcc gcc-c++ glibc libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
複製代碼
下載 php-5.6.30.tar.gzphp
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt --enable-mbstring --enable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar
make
make install
複製代碼
cp php.ini-production /usr/local/php/lib/php.ini
複製代碼
cd /usr/local/php
cp etc/php-fpm.conf.default etc/php-fpm.conf
vim etc/php-fpm.conf
複製代碼
修改如下內容html
pm.max_children = 150
pm.start_servers = 8
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pid = /usr/local/php/var/run/php-fpm.pid
複製代碼
執行如下命令:node
/usr/local/php/sbin/php-fpm
複製代碼
使用以下命令來驗證(若是此命令輸出有中幾個php-fpm進程就說明啓動成功了):mysql
ps aux | grep php-fpm
複製代碼
yum install gcc automake autoconf libtool make gcc-c++ readline readline-devel pcre pcre-devel opemssl openssl-devel zlib zlib-devel
複製代碼
爲利於後期開發,nginx採用 openrestylinux
./configure --prefix=/usr/local/openresty/nginx --sbin-path=/usr/local/openresty/nginx/sbin/nginx --conf-path=/usr/local/openresty/nginx/nginx.conf --pid-path=/usr/local/openresty/nginx/nginx.pid --with-http_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi
make
make install
複製代碼
編輯文件/usr/local/openresty/nginx/nginx.conf
,如下內容的「#」號去掉,結果以下:nginx
log_format main '$remote_addr - $remote_user [$time_local] "$request"'
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
location / {
root html;
index index.html index.htm;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
#include fastcgi_params;
include fastcgi.conf;
}
複製代碼
從新載入nginx的配置文件c++
/usr/local/openresty/nginx/sbin/nginx -s reload
複製代碼
在/usr/local/openresty/nginx/html
下建立index.php文件,輸入以下內容sql
<?php
phpinfo();
?>
複製代碼
瀏覽器訪問http://你的服務器ip/index.php
,便可以見到php信息了。shell
非本機訪問須要開啓防火牆策略數據庫
firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,沒有此參數重啓後失效)
firewall-cmd --reload
複製代碼
下載 mysql-5.7.16-linux-glibc2.5-x86_64.tar
rpm -qa | grep mysql
mysql-libs-5.1.52-1.el6_0.1.x86_64
rpm -e mysql-libs-5.1.52.x86_64 --nodeps
複製代碼
cat /etc/group | grep mysql
mysql:x:490:
cat /etc/passwd | grep mysql
mysql:x:496:490::/home/mysql:/bin/bash
複製代碼
以上爲默認存在的狀況,如無,執行添加命令:
groupadd mysql
useradd -r -g mysql mysql //useradd -r參數表示mysql用戶是系統用戶,不可用於登陸系統。
複製代碼
cd /usr/local/
tar xvf mysql-5.7.12-linux-glibc2.5-x86_64.tar
ls -l
tar xvfz mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.12-linux-glibc2.5-x86_64 mysql
chown -R mysql mysql/
chgrp -R mysql mysql/
cd mysql/
複製代碼
bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
複製代碼
若是改變默認安裝路徑,則須要
一、/etc/my.cnf、/etc/init.d/mysqld中修改
basedir='/apps/mysql'
datadir='/apps/mysql/data'
二、建立ln
mkdir -p /usr/local/mysql/bin
ln -s /apps/mysql/bin/mysqld /usr/local/mysql/bin/mysqld`
複製代碼
cp -a ./support-files/my-default.cnf /etc/my.cnf
cp -a ./support-files/mysql.server /etc/init.d/mysqld
cd bin/
./mysqld_safe --user=mysql &
/etc/init.d/mysqld restart
複製代碼
chkconfig --level 35 mysqld on
複製代碼
mysql5.7會生成一個初始化密碼,而在以前的版本首次登錄不須要登陸。
cat /root/.mysql_secret
./mysql -uroot -p
Enter password:
mysql> SET PASSWORD = PASSWORD('********');
mysql> flush privileges;
//重啓生效
/etc/init.d/mysqld restart
複製代碼
一些漏洞環境(dvwa)數據庫鏈接改用pdo,如未安裝,可在此進行安裝。
在PHP源碼包中進入ext/pdo_mysql,按如下步驟執行。
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make
make install
複製代碼
注: 個人PHP安裝在:/usr/local/php/,mysql安裝在:/usr/local/mysql,編譯的時候注意你本身的安裝目錄在哪裏。
修改配置文件php.ini
打開並添加
extension=pdo_mysql.so
extension=pdo.so
複製代碼
重啓php-fpm