CentOS 7
主機:lamp.example.com
IP:192.168.100.10
1、關閉防火墻與selinux
# 關閉防火墻systemctl stop firewalldsystemctl disable firewalld# 關閉selinuxvim /etc/selinux/config # 或vim /etc/sysconfig/selinuxSELINUX=disabled:wq# 重啟reboot
2、開啟時鐘同步
yum -y install chrony # 如果沒有的話 systemctl restart chronyd systemctl enable chronyd hwclock -w
3、安裝httpd與mariadb數據庫
cd /etc/yum.repos.d/rm -rf * # 刪除原有的.repo# 使用阿里源curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo# 下載epel-release源yum -y install epel-release
# 下載httpd、mariadb、mariadb-serveryum -y install httpdyum -y install mariadbyum -y install mariadb-server
4、初始化數據庫
systemctl restart mariadbsystemctl enable mariadbmysql_secure_installation# Set root password? [Y/n] y# Remove anonymous users? [Y/n] y# Disallow root login remotely? [Y/n] n# Remove test database and access to it? [Y/n] y# Reload privilege tables now? [Y/n] y
5、安裝PHP
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utilsyum-config-manager --enable remi-php70
yum -y install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlndpvp -v # 查看PHP
6、配置php,將時區改成亞洲/上海
vim /etc/php.ini date.timezone = Asia/Shanghai :wq systemctl restart php-fpm systemctl enable php-fpm
7、配置默認網頁
vim /etc/httpd/conf/httpd.conf<IfModule dir_module>DirectoryIndex index.html index.php </IfModule>:wq
vim /var/www/html/index.php <?phpphpinfo(); ?> :wqsystemctl restart httpd systemctl enable httpd
8、測試訪問lamp基礎架構
在本地瀏覽器上輸入192.168.100.70
9、將wordpress壓縮包上傳到服務器并解壓
mkdir /myforum cd /myforum
直接wordpress壓縮包拖入Xshell中
tar -xzvf wordpress-6.5.5.tar.gz
cp -R /myforum/wordpress /var/www/html/
10、設置wordpress的權限
chown -R apache.apache /var/www/html/wordpress chmod -R 775 /var/www/html/wordpress
11、為wordpress配置數據庫
mysql -u root -p
create database wordpress_db create user 'wordpress_user'@'localhost' identified by '123456'; grant all on wordpress_db.* to 'wordpress_user'@'localhost'; flush privileges; exit
12、為wordpress部署站點
cp -p /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/ vim /etc/httpd/conf.g/httpd-vhosts.conf<VirtualHost 192.168.100.70:80>DocumentRoot "/var/www/html/wordpress/"<Directory "/var/www/thml/wordpress">Options Indexes FollowSymLinksAllowOverride NoneRequire all granted </Directory> </VirtualHost>:wq # 重啟httpd服務 systemctl restart httpd
13、使用瀏覽器訪問wordpress站點
打開瀏覽器輸入192.168.100.70/wp-admin
輸入數據庫名、用戶名、密碼;注意不要輸錯