基于ubuntu 22.04 LTS的VPS服务器(linode 2G)
一、基础设置
1.设置时区
dpkg-reconfigure tzdata
2.修改SSH端口
vi /etc/ssh/sshd_config
找到#Port 22 去掉#注释,改成任意端口号,如:Port 1234
Port 1234
3.重启SSH服务
sudo service sshd restart
4.系统更新
apt-get update
apt-get upgrade –show-upgraded
二、LAMP与Wordpress安装
1.安装Apache web server
sudo apt install apache2
- 安装MySQL web server
sudo apt install mysql-server
3.安装PHP
sudo apt install php libapache2-mod-php php-mysql
4.安装Wordpress
sudo apt install wordpress
三、为ubuntu 22.04 LTS 配置LAMP
1.配置Apache Web服务器
修改文件:/etc/apache2/apache2.conf
KeepAlive On
MaxKeepAliveRequests 50
KeepAliveTimeout 5
2.基于2GB Linode进行优化,修改文件:/etc/apache2/mods-available/mpm_prefork.conf
StartServers 4 MinSpareServers 3 MaxSpareServers 40 MaxRequestWorkers 200 MaxConnectionsPerChild 10000
3.重启Apache
sudo systemctl restart apache2
- 确保 Apache 在重新启动后仍然有效:
sudo systemctl status apache2
5.Apache现在已经准备好,请使用web浏览器访问服务器的ip地址,如果成功,浏览器将显示Apache2的欢迎页面
http://hug.app/
四、在 Apache 上配置域名与服务器主机
1.使用默认文件为新主机进行配置
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/wordpress.conf
2.为此域名修改配置文件
修改文件:/etc/apache2/sites-available/wordpress.conf
SSLEngine on
ServerName domain.com
ServerAlias www.domain.dom
SSLCertificateFile /etc/apache2/ssl/domain.crt
SSLCertificateKeyFile /etc/apache2/ssl/domain.key
DocumentRoot /var/www/html/wordpress
3.作为安全预防措施,禁用默认站点:
sudo a2dissite 000-default.conf
4.重新加载 Apache 以应用所有更改:
sudo systemctl reload apache2
5.运行Apache测试工具,提示Syntax OK则有效
sudo apache2ctl configtest
五、配置MySQL数据库
- 以用户身份登录 MySQL shell
sudo mysql -u root
2.在MySQL中,创建数据库。
CREATE DATABASE webdata;
CREATE USER ‘webuser’ IDENTIFIED BY ‘password’;
GRANT ALL ON webdata.* TO ‘webuser’;
3.退出SQL
quit
