yum源安装
安装依赖包
yum install pcre-devel zlib-devel openssl-devel
安装需要的服务
yum -y install nginx php-mysql mysql mariadb-server php-fpm
创建nginx的启动用户
useradd -r www
修改nginx的配置nginx.conf
user www; worker_processes auto;
修改php-fpm的启动用户
user = www group = www
创建php-fpm的session目录
[root@centos7 nginx]# mkdir /var/lib/php/session/ [root@centos7 nginx]# chown -R www.www /var/lib/php/session/
启动mariadb服务
[root@centos7 vhost1]# systemctl start mariadb.service [root@centos7 vhost1]# systemctl enable mariadb.service //开机启动
创建所需要的库
MariaDB [(none)]> CREATE DATABASE wps; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> GRANT ALL ON wps.* TO 'wps_user'@'192.168.%.%' IDENTIFIED BY 'wps_pass'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec
开启php-fpm服务
[root@centos7 conf.d]# systemctl start php-fpm.service [root@centos7 conf.d]# systemctl enable php-fpm.service //开机启动 Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
配置nginx虚拟主机wps.conf
[root@centos7 conf.d]# cat wps.conf server { listen 80; server_name www.runner.vip; location / { root /apps/vhost1/wordpress; } index index.php index.html index.htm; location ~ \.php$ { root /apps/vhost1/wordpress; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /apps/vhost1/wordpress$fastcgi_script_name; #需要指定我们指定存放php程序网站的路径 include fastcgi_params; } }
配置ssl虚拟主机ssl.conf
[root@centos7 conf.d]# cat ssl.conf server { listen 443 ssl; server_name myadmin.runner.vip; ssl_certificate /etc/nginx/ssl/nginx.crt; #从CA申请过来的证书 ssl_certificate_key /etc/nginx/ssl/httpd.key; #私钥 ssl_session_cache shared:SSL:1m; #ssl会话共享缓存,1分钟时间 ssl_session_timeout 5m; #ssl会话超时时间5分钟 ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root /apps/vhost2/phpmyadmin; index index.php index.html index.htm; } location ~ \.php$ { root /apps/vhost2/phpmyadmin; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /apps/vhost2/phpmyadmin$fastcgi_script_name; #需要指定我们指定存放php程序网站的路径 include fastcgi_params; } }
访问页面出现错误
myadmin.runner.vip 网页无法正常运作
myadmin.runner.vip 目前无法处理此请求。
HTTP ERROR 500
查看错误日志
[root@centos7 conf.d]# tail /var/log/php-fpm/www-error.log [29-Jul-2016 08:28:22 UTC] PHP Fatal error: Call to undefined function mb_detect_encoding() in /apps/vhost2/phpMyAdmin-4.3.5-all-languages/libraries/php-gettext/gettext.inc on line 177 [29-Jul-2016 08:28:25 UTC] PHP Fatal error: Call to undefined function mb_detect_encoding() in /apps/vhost2/phpMyAdmin-4.3.5-all-languages/libraries/php-gettext/gettext.inc on line 177 [29-Jul-2016 08:28:52 UTC] PHP Fatal error: Call to undefined function mb_detect_encoding() in /apps/vhost2/phpMyAdmin-4.3.5-all-languages/libraries/php-gettext/gettext.inc on line 177 [29-Jul-2016 08:28:57 UTC] PHP Fatal error: Call to undefined function mb_detect_encoding() in /apps/vhost2/phpMyAdmin-4.3.5-all-languages/libraries/php-gettext/gettext.inc on line 177 [29-Jul-2016 08:31:37 UTC] PHP Fatal error: Call to undefined function mb_detect_encoding() in /apps/vhost2/phpMyAdmin-4.3.5-all-languages/libraries/php-gettext/gettext.inc on line 177 [29-Jul-2016 08:31:50 UTC] PHP Fatal error: Call to undefined function mb_detect_encoding() in /apps/vhost2/phpMyAdmin-4.3.5-all-languages/libraries/php-gettext/gettext.inc on line 177
需要安装依赖包
[root@centos7 conf.d]# yum -y install php-mbstring [root@centos7 conf.d]# systemctl reload php-fpm.service 重启php-fpm服务
打开浏览器访问
源码包安装
安装包组
[root@centos7 ~]# yum -y groupinstall "Server Platform Development" "Development Tools"
下载nginx源码包
[root@centos7 src]# wget http://nginx.org/download/nginx-1.10.1.tar.gz
编译安装nginx
./configure --prefix=/usr/local/nginx \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --user=nginx --group=nginx \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_dav_module \ --with-http_stub_status_module \ --with-threads \ --with-file-aio make && make install
安装mariadb 二进制包
[root@centos7 src]# mkdir /data/mysql -pv [root@centos7 src]# groupadd -r -g 306 mysql [root@centos7 src]# useradd -g mysql -s /sbin/nologin mysql [root@centos7 src]# chown -R mysql.mysql /data/mysql/ [root@centos7 src]# mv mariadb-5.5.46-linux-x86_64 /usr/local/ [root@centos7 src]# ln -sv /usr/local/mariadb-5.5.46-linux-x86_64/ /usr/local/mysql ‘/usr/local/mysql’ -> ‘/usr/local/mariadb-5.5.46-linux-x86_64/’ [root@centos7 src]# cd /usr/local/mysql/ [root@centos7 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql [root@centos7 mysql]# cp support-files/my-large.cnf /etc/my.cnf cp: overwrite ‘/etc/my.cnf’? y [root@centos7 mysql]# vim /etc/my.cnf [mysqld] port = 3306 socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 256M max_allowed_packet = 1M table_open_cache = 256 sort_buffer_size = 1M read_buffer_size = 1M read_rnd_buffer_size = 4M myisam_sort_buffer_size = 64M thread_cache_size = 8 query_cache_size= 16M datadir = /data/mysql innodb_file_per_table = ON skip_name_resolve = ON thread_concurrency = 8 [root@centos7 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql [root@centos7 mysql]# /etc/init.d/mysql start Starting MySQL.. SUCCESS!
安装php-fpm所依赖的安装包
yum install libxml2-develgd-devel freetype-devel libmcrypt-devel yum install pcre-developenssl-devel libevent-devel
[root@centos7 php-5.4.40]# ./configure --prefix=/usr/local/php-fpm \ --with-mysql=/usr/local/mysql \ --with-openssl \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --enable-mbstring \ --enable-xml \ --enable-sockets \ --with-freetype-dir \ --with-gd \ --with-libxml-dir=/usr/ \ --with-zlib \ --with-jpeg-dir \ --with-png-dir \ --with-mcrypt \ --with-config-file-path=/etc/php.d/php.ini \ --with-config-file-scan-dir=/etc/php.d \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable-fpm [root@centos7 php-5.4.40]# cp php.ini-production /etc/php.d/php.ini [root@centos7 php-5.4.40]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm [root@centos7 fpm]# chmod +x /etc/rc.d/init.d/php-fpm 安装xcache插件 [root@centos7 src]# tar jxf xcache-3.2.0.tar.bz2 [root@centos7 src]# cd xcache-3.2.0/ [root@centos7 xcache-3.2.0]# phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 [root@centos7 xcache-3.2.0]# ./configure --enable-xcache --with-php-config=/usr/local/php-fpm/bin/php-config [root@centos7 xcache-3.2.0]# make && make install [root@centos7 xcache-3.2.0]# cp xcache.ini /etc/php.d/ [root@centos7 xcache-3.2.0]# /etc/init.d/php-fpm restart Gracefully shutting down php-fpm . done Starting php-fpm done
准备数据库
MariaDB [(none)]> CREATE DATABASE wps; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> GRANT ALL ON wps.* TO 'wps_user'@'192.168.%.%' IDENTIFIED BY 'wps_pass'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES -> ; Query OK, 0 rows affected (0.00 sec)
配置nginx虚拟主机
[root@centos7 conf.d]# cat wps.conf server { listen 80; server_name www.runner.vip; location / { root /apps/vhost1/wordpress; index index.php index.html; } location ~ \.php$ { root /apps/vhost1/wordpress; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /apps/vhost1/wordpress$fastcgi_script_name; #需要指定我们指定存放php程序网站的路径 include fastcgi_params; } }