WordPress·環(huán)境

在開端中提到的文章里有詳盡的傻瓜式建站教學,但是我在看到lamp一鍵安裝以后就拒絕了……大概是我內(nèi)心可惡的程序猿自尊在作祟吧。因為自己的 vps 的系統(tǒng)是 centOS7 ,之后搜索關(guān)鍵詞,搭載好 lamp 以后再回頭發(fā)現(xiàn)用不了那篇教程了。于是繼續(xù)搜索各種教程,磕磕絆絆做好了網(wǎng)站的殼子。

升級 centOS 內(nèi)核和 yum

  1. yum更新系統(tǒng)版本:
[root@server ~]# yum update
  1. 查看系統(tǒng)版本:
[root@server ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
  1. 安裝elrepo并升級內(nèi)核:
[root@server ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@server ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
[root@server ~]# yum --enablerepo=elrepo-kernel install kernel-ml -y
  1. 更新grub文件并重啟系統(tǒng):
[root@server ~]# egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \'
CentOS Linux 7 Rescue 8619ff5e1306499eac41c02d3b23868e (4.14.14-1.el7.elrepo.x86_64)
CentOS Linux (4.14.14-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.11.6.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-c73a5ccf3b8145c3a675b64c4c3ab1d4) 7 (Core)
[root@server ~]# grub2-set-default 0
[root@server ~]# reboot
  1. 重啟完成后查看內(nèi)核是否已更換為新版本:
[root@server ~]# uname -r
  1. 開啟bbr:
[root@server ~]# vim /etc/sysctl.conf    # 在文件末尾添加如下內(nèi)容
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
  1. 加載系統(tǒng)參數(shù):
[root@vultr ~]# sysctl -p
net.ipv6.conf.all.accept_ra = 2
net.ipv6.conf.eth0.accept_ra = 2
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
[root@vultr ~]#

如上,輸出了我們添加的那兩行配置代表正常。

  1. 確定bbr已經(jīng)成功開啟:
[root@vultr ~]# sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = bbr cubic reno
[root@vultr ~]# lsmod | grep bbr
tcp_bbr                20480  2 
[root@vultr ~]# 

輸出內(nèi)容如上,則表示bbr已經(jīng)成功開啟。

LAMP是什么

引用文章:https://blog.csdn.net/sj349781478/article/details/84224440

LAMP(Linux + Apache + MySQL/MariaDB/Percona + PHP)

  • L:Linux 系統(tǒng),需注意系統(tǒng)的版本號,如 Centos6.9 或 Centos7.3 ;
  • A:Apache ,在傳統(tǒng)行業(yè)中,多數(shù)采用 Apache 服務(wù)器,因此也很有必要了解學習 Apache ;
  • M:數(shù)據(jù)庫,多數(shù)采用 MySQL 或 MariaDB ,作為專業(yè)的數(shù)據(jù)庫工程師需經(jīng)多年的歷練;
  • P:PHP 編程語言。

用yum快速搭建LAMP

原文鏈接:https://www.cnblogs.com/me80/p/7218883.html

LAMP架構(gòu)

安裝 Apache

  1. 安裝 Apache
[root@server ~]# yum install httpd httpd-devel
  1. 啟動 Apache 服務(wù)
[root@server ~]# systemctl start httpd
  1. 設(shè)置 httpd 服務(wù)開機啟動
[root@server ~]# systemctl enable  httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service
to /usr/lib/systemd/system/httpd.service.
  1. 查看服務(wù)狀態(tài)
[root@server ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2017-07-21 17:21:37 CST; 6min ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 2449 (httpd)
   Status: "Total requests: 11; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─2449 /usr/sbin/httpd -DFOREGROUND
           ├─2450 /usr/sbin/httpd -DFOREGROUND
           ├─2451 /usr/sbin/httpd -DFOREGROUND
           ├─2452 /usr/sbin/httpd -DFOREGROUND
           ├─2453 /usr/sbin/httpd -DFOREGROUND
           ├─2454 /usr/sbin/httpd -DFOREGROUND
           ├─2493 /usr/sbin/httpd -DFOREGROUND
           ├─2494 /usr/sbin/httpd -DFOREGROUND
           └─2495 /usr/sbin/httpd -DFOREGROUND

7月 21 17:21:35 nmserver-7.test.com systemd[1]: Starting The Apache HTTP Server...
7月 21 17:21:36 nmserver-7.test.com httpd[2449]: AH00558: httpd: Could not reliably determine 
the server's fully q...ssage
7月 21 17:21:37 nmserver-7.test.com systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
  1. 防火墻設(shè)置開啟 80 端口
[root@server ~]# firewall-cmd --permanent --zone=public  --add-service=http
success
[root@server ~]# firewall-cmd --permanent --zone=public  --add-service=https
success
[root@server ~]# firewall-cmd --reload
success</pre>
  1. 安裝網(wǎng)絡(luò)工具
[root@server ~]# yum install net-tools
  1. 確認 80 端口監(jiān)聽狀態(tài)
[root@server ~]# yum install net-tools
[root@server ~]# netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address       Foreign Address       State       PID/Program name    
tcp        0      0 0.0.0.0:ssh         0.0.0.0:*             LISTEN      1084/sshd           
tcp        0      0 localhost:smtp      0.0.0.0:*             LISTEN      1486/master         
tcp6       0      0 [::]:ssh            [::]:*                LISTEN      1084/sshd           
tcp6       0      0 localhost:smtp      [::]:*                LISTEN      1486/master         
*  tcp6    0      0 [::]:http           [::]:*                LISTEN      2449/httpd   *
udp        0      0 localhost:323       0.0.0.0:*                         592/chronyd         
udp6       0      0 localhost:323       [::]:*                            592/chronyd
  1. 查看服務(wù)器IP
[root@server ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:56:bc:cf brd ff:ff:ff:ff:ff:ff
    inet 192.168.8.9/24 brd 192.168.8.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe56:bccf/64 scope link 
       valid_lft forever preferred_lft forever
3: bridge0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether ea:89:d5:c7:32:73 brd ff:ff:ff:ff:ff:ff
  1. 使用瀏覽器訪問
Apache測試界面

安裝 MySQL

  1. 安裝 MySQL
[root@server ~]# rpm -qa |grep maria
mariadb-libs-5.5.52-1.el7.i686
mariadb-5.5.52-1.el7.i686
mariadb-server-5.5.52-1.el7.i686
mariadb-devel-5.5.52-1.el7.i686</pre>
  1. 開啟 MySQL 服務(wù),并設(shè)置開機啟動,檢查 MySQL 狀態(tài)
[root@server ~]# systemctl start  mariadb 
[root@server ~]# systemctl enable  mariadb 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service 
to /usr/lib/systemd/system/mariadb.service.
[root@server ~]# systemctl status  mariadb 
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2017-07-22 21:19:20 CST; 21s ago
 Main PID: 9603 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─9603 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─9760 /usr/libexec/mysqld --basedir=/usr --datadir=/v...

7月 22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...
7月 22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...
7月 22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...
7月 22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...
7月 22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...
7月 22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...
7月 22 21:19:15 nmserver-7.test.com mariadb-prepare-db-dir[9524]: ...
7月 22 21:19:16 nmserver-7.test.com mysqld_safe[9603]: 170722 21...
7月 22 21:19:16 nmserver-7.test.com mysqld_safe[9603]: 170722 21...
7月 22 21:19:20 nmserver-7.test.com systemd[1]: Started MariaDB ...
[root@server ~]# netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address       Foreign Address       State       PID/Program name    
tcp        0      0 0.0.0.0:ssh         0.0.0.0:*             LISTEN      1084/sshd           
*  tcp     0      0 0.0.0.0:mysql       0.0.0.0:*             LISTEN      9760/mysqld  *
tcp6       0      0 [::]:ssh            [::]:*                LISTEN      1084/sshd           
tcp6       0      0 [::]:http           [::]:*                LISTEN      2449/httpd          
udp        0      0 localhost:323       0.0.0.0:*                         592/chronyd         
udp6       0      0 localhost:323       [::]:*                            592/chronyd
  1. 數(shù)據(jù)庫安全設(shè)置
    引用文章:https://blog.csdn.net/qq_32786873/article/details/78846008
    為了好看這里用了vb的語法高亮,請忽略蜜汁紫字
[root@localhost ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): <–初次運行直接回車
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n]    #是否設(shè)置root用戶密碼,輸入y并回車或直接回車
New password:               #設(shè)置root用戶的密碼
Re-enter new password:      #再輸入一次你設(shè)置的密碼
Password updated successfully!
Reloading privilege tables..
… Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL 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.
Remove anonymous users? [Y/n]   #是否刪除匿名用戶,生產(chǎn)環(huán)境建議刪除,所以直接回車
… Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n]   #是否禁止root遠程登錄,根據(jù)自己的需求選擇Y/n并回車,建議禁止
… Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n]   #是否刪除test數(shù)據(jù)庫,直接回車
- Dropping test database…
… Success!
- Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n]   #是否重新加載權(quán)限表,直接回車
… Success!
Cleaning up…
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
  1. 登陸數(shù)據(jù)庫測試
[root@server ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11 Server version: 5.5.52-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases; +--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.02 sec)

MariaDB [(none)]>

ctrl z 退出

安裝 PHP

  1. 安裝 PHP
[root@server ~]# yum -y install php
[root@server ~]# rpm -ql php
/etc/httpd/conf.d/php.conf
/etc/httpd/conf.modules.d/10-php.conf
/usr/lib/httpd/modules/libphp5.so
/usr/share/httpd/icons/php.gif
/var/lib/php/session
  1. 將 PHP 與 MySQL 關(guān)聯(lián)起來
[root@server ~]# yum install php-mysql
[root@nmserver-7 ~]# rpm -ql php-mysql
/etc/php.d/mysql.ini /etc/php.d/mysqli.ini
/etc/php.d/pdo_mysql.ini
/usr/lib/php/modules/mysql.so
/usr/lib/php/modules/mysqli.so
/usr/lib/php/modules/pdo_mysql.so
  1. 安裝常用 PHP 模塊
[root@server ~]# yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath</pre>
  1. 生成 PHP 測試文件
[root@server ~]# cd  /var/www/html/
[root@nmserver-7 html]# ls
[root@nmserver-7 html]# pwd
/var/www/html
[root@nmserver-7 html]# vi info.php

<?php
        phpinfo();
?>
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                            
:wq</pre>
  1. 重啟 Apache 服務(wù)器
[root@server ~]# systemctl restart httpd
  1. 用瀏覽器查看 PHP 信息
可以看到已經(jīng)安裝的模塊
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容