yum安裝lnmp+wordpress
基礎配置
xserver1解壓打開虛擬機配置ip
掛載鏡像
# mkdir /opt/centos
# mount CentOS-7-x86_64-DVD-1511.iso /opt/centos/
配置本地yum源文件
# mv /etc/yum.repos.d/* /media/
# vi /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[lnmp]
name=lnmp
baseurl=file:///root/lnmp
gpgcheck=0
enabled=1
關閉防火牆
# setenforce 0
# systemctl stop firewalld
安裝配置lnmp
安裝服務
# yum install -y nginx mariadb mariadb-server php-fpm php-mysql
創建目錄
# mkdir /www
# chown nginx:nginx /www/
編輯nginx文件
# vi /etc/nginx/fastcgi_params
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; //添加這行
fastcgi_param REQUEST_URI $request_uri;
# vi /etc/nginx/conf.d/default.conf
location / {
root /www; //更改網頁目錄
index index.php index.html index.htm; //添加index.php
}
location ~ \.php$ { //去掉這部分前面的注釋符
root /www; //更改目錄
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
啟動服務
# systemctl start nginx
查看服務狀態
# systemctl status nginx
編輯php文件
# vi /etc/php-fpm.d/www.conf
user = nginx //修改用戶和組
group = nginx
啟動服務
# service php-fpm start
Redirecting to /bin/systemctl start php-fpm.service
查看服務狀態
# systemctl status php-fpm
初始化數據庫
# systemctl start mariadb
# mysql_secure_installation
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
OK, successfully used password, moving on...
root user without the proper authorisation.
New password: ##輸入數據庫root密碼
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
... Success!
ensures that someone cannot guess at the root password from the network.
... skipping.
access. This is also intended only for testing, and should be removed
before moving into a production environment.
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
will take effect immediately.
... Success!
installation should now be secure.
進入數據庫
# mysql -uroot -p000000
授權在任何客戶端機器上可以以root用戶登錄到數據庫
> grant all privileges on *.* to root@'%' identified by '000000';
創建數據庫
> create database wordpress;
退出數據庫
查看端口
# yum install -y net-tools
# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3458/php-fpm: maste
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3854/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3449/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1422/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2025/master
tcp6 0 0 :::22 :::* LISTEN 1422/sshd
tcp6 0 0 ::1:25 :::* LISTEN 2025/master
部署wordpress
解壓文件
# yum install -y unzip
# unzip wordpress-4.7.3-zh_CN.zip
修改配置文件
# mv wordpress/* /www/
# cp /www/wp-config-sample.php /www/wp-config.php
# vi /www/wp-config.php
// ** MySQL 設置 - 具體信息來自您正在使用的主機 ** //
/** WordPress數據庫的名稱 */
define('DB_NAME', 'wordpress');
/** MySQL數據庫用戶名 */
define('DB_USER', 'root');
/** MySQL數據庫密碼 */
define('DB_PASSWORD', '000000');
/** MySQL主機 */
define('DB_HOST', '192.168.100.10');
/** 創建數據表時默認的文字編碼 */
define('DB_CHARSET', 'utf8');
/** 數據庫整理類型。如不確定請勿更改 */
define('DB_COLLATE', '');
網頁訪問ip
設置WordPress的站點標題為自己的姓名