环境:
centos 7.4
关闭防火墙
关闭selinux
LNMP的搭建
1.安装包 开启服务
yum -y install nginx mariadb-server php-fpm php-mysql
nginx
systemctl start mariadb
systemctl start php-fpm
2、修改nginx的配置文件
vim /etc/nginx/nginx.conf 修改下面几类
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 65535;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name www.cwf.com;
location / {
root /data/www;
index index.html index.htm index.php;
}
access_log /logs/access_www.log main;
location ~ \.php$ {
#开启.php,配置文件有例子,只需去掉注释,修改一行即可
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /data/php/index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
include /etc/nginx/conf.d/*.conf;
}
修改完,可以nginx -t 查看
然后没问题在启动nginx
ulimit -n 查看linux系统里打开文件描述符的最大值,一般缺省值是1024,对一台繁忙的服务器来说,这个值偏小,所以有必要重新设置linux系统里打开文件描述符的最大值
ulimit -n 65535 修改内核参数
3、修改php-fpm的配置文件
① vim /etc/php.ini 改两行
date.timezone = Asia/Shanghai 时区
short_open_tag = On 允许短标签
② vim /etc/php-fpm.d/www.conf 改两行
user = nginx
group = nginx
③ systemctl restart php-fpm
4、运行mysql ,创建一会网页需要的库
systemctl start mariadb
mysql_secure_installation 初始化
MariaDB [(none)]> create database bb;
Query OK, 1 row affected (0.00 sec)
5、部署
把上传的源码 放在 /data/www 目录下
[root@web1 data]# chown -R nginx:nginx www/
[root@web1 www]# cp wp-config-sample.php wp-config.php
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define('DB_NAME', 'wp');
/** MySQL数据库用户名 */
define('DB_USER', 'root');
/** MySQL数据库密码 */
define('DB_PASSWORD', '123456');
/** MySQL主机 */
define('DB_HOST', 'localhost');
/** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8');
/** 数据库整理类型。如不确定请勿更改 */
define('DB_COLLATE', '');
浏览器打开
http://www.cwf.com/wp-admin/install.php
安装完成后进行登陆