一、编译安装LNMP,并安装wordpress
1、下载nginx并解压缩。
root@ubuntu:~# wget http://nginx.org/download/nginx-1.18.0.tar.gzroot@ubuntu:~# tar -xf nginx-1.18.0.tar.gz
root@ubuntu:~# wget http://nginx.org/download/nginx-1.18.0.tar.gz
root@ubuntu:~# tar -xf nginx-1.18.0.tar.gz
2、安装编译安装需要的依赖包。
root@ubuntu:~# apt install -y gcc libgd-dev libgeoip-dev libpcre3 libpcre3-dev libssl-dev openssl
3、开始编译安装。
root@ubuntu:~# cd nginx-1.18.0/root@ubuntu:~/nginx-1.18.0# root@ubuntu:~/nginx-1.18.0# ./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_moduleroot@ubuntu:~/nginx-1.18.0# make -j 4root@ubuntu:~/nginx-1.18.0# make install
root@ubuntu:~# cd nginx-1.18.0/
root@ubuntu:~/nginx-1.18.0#
root@ubuntu:~/nginx-1.18.0# ./configure --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module
--with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module
--with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
root@ubuntu:~/nginx-1.18.0# make -j 4
root@ubuntu:~/nginx-1.18.0# make install
4、创建nginx用户和组,修改/apps/nginx目录所属用户和所属组。
root@ubuntu:~/nginx-1.18.0# addgroup --gid 2000 nginxAdding group `nginx' (GID 2000) ...Done.root@ubuntu:~/nginx-1.18.0# useradd -m -r -s /bin/bash -u 2000 -g 2000 nginxroot@ubuntu:~/nginx-1.18.0# chown nginx.nginx -R /apps/nginx/
root@ubuntu:~/nginx-1.18.0# addgroup --gid 2000 nginx
Adding group `nginx' (GID 2000) ...
Done.
root@ubuntu:~/nginx-1.18.0# useradd -m -r -s /bin/bash -u 2000 -g 2000 nginx
root@ubuntu:~/nginx-1.18.0# chown nginx.nginx -R /apps/nginx/
5、修改nginx配置文件。
root@ubuntu:~/nginx-1.18.0# vim /apps/nginx/conf/nginx.confhttp { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root /apps/nginx/html; index index.html index.htm index.php; } location ~ \.php$ { root /apps/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;} error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }
root@ubuntu:~/nginx-1.18.0# vim /apps/nginx/conf/nginx.conf
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /apps/nginx/html;
index index.html index.htm index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
6、启动nginx。
root@ubuntu:~/nginx-1.18.0# /apps/nginx/sbin/nginx root@ubuntu:/apps/nginx/html# echo nginx > /apps/nginx/html/index.htmlroot@ubuntu:/apps/nginx/html# curl 10.0.0.135nginx
root@ubuntu:~/nginx-1.18.0# /apps/nginx/sbin/nginx
root@ubuntu:/apps/nginx/html# echo nginx > /apps/nginx/html/index.html
root@ubuntu:/apps/nginx/html# curl 10.0.0.135
nginx
7、安装php-fpm。
root@ubuntu:/apps/nginx/html# apt install php-fpm php-json php-mysqlnd
8、修改php配置文件。
#修改下面开头的几行root@ubuntu:~# vim /etc/php/7.2/fpm/pool.d/www.conf user = nginxgroup = nginxlisten =127.0.0.1:9000
#修改下面开头的几行
root@ubuntu:~# vim /etc/php/7.2/fpm/pool.d/www.conf
user = nginx
group = nginx
listen =127.0.0.1:9000
9、安装mysql
root@ubuntu1:/apps/nginx/html# apt install mysql-server
10、创建wordpress数据库账号、密码
root@ubuntu:/apps/nginx/html# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.7.32-0ubuntu0.18.04.1 (Ubuntu)Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> CREATE DATABASE wordpress;Query OK, 1 row affected (0.00 sec)mysql> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost" IDENTIFIED BY "123456";Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.00 sec)mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys || wordpress |+--------------------+5 rows in set (0.00 sec)
root@ubuntu:/apps/nginx/html# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.32-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost" IDENTIFIED BY "123456";
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
| information_schema |
| mysql |
| performance_schema |
| sys |
| wordpress |
5 rows in set (0.00 sec)
11、下载wordpress,解压缩,设置权限。
root@ubuntu:/apps/nginx/html# tar -xf wordpress-5.6-zh_CN.tar.gzroot@ubuntu:/apps/nginx/html# chown nginx.nginx -R /apps/nginx/html/wordpress
root@ubuntu:/apps/nginx/html# tar -xf wordpress-5.6-zh_CN.tar.gz
root@ubuntu:/apps/nginx/html# chown nginx.nginx -R /apps/nginx/html/wordpress
12、访问wordpress页面进行初始化。
二、配置虚拟主机,www.x.com域名实现首页访问,admin.x.com域名实现wordpress的后台访问。
1、本实验在上例的基础上完成。
2、修改windows的host文件,添加下面内容。
10.0.0.135 www.x.com10.0.0.135 admin.x.com
10.0.0.135 www.x.com
10.0.0.135 admin.x.com
3、修改nginx配置文件,添加下面虚拟主机,重启nginx服务。
server { listen 80; server_name www.x.com; location / { root /apps/nginx/html/wordpress; index index.html index.php; } location ~ \.php$ { root /apps/nginx/html/wordpress; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}server { listen 80; server_name admin.x.com; location / { root /apps/nginx/html/wordpress/wp-admin; index index.html index.php; } location ~ \.php$ { root /apps/nginx/html/wordpress/wp-admin; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}root@ubuntu:~# /apps/nginx/sbin/nginx -s reload
server_name www.x.com;
root /apps/nginx/html/wordpress;
index index.html index.php; }
server_name admin.x.com;
root /apps/nginx/html/wordpress/wp-admin;
root@ubuntu:~# /apps/nginx/sbin/nginx -s reload
4、使用域名访问wordpress。 成功访问后先登录管理后台 仪表盘——>设置——>常规——>WordPress地址(URL) 和 站点地址(URL)改为http://www.x.com,否则后续访问地址会变成ip地址。
原文链接:http://www.cnblogs.com/lele3721/p/14323855.html
本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728