ubuntu lamp 搭建(Apache+PHP+Mysql环境)

ubuntu lamp 搭建(Apache+PHP+Mysql环境)

ubuntu lamp

首先安装环境lamp(Apache+PHP+Mysql环境)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

sudo apt install apache2 //(1)安装apache

sudo apt install mysql-server-8.0 mysql-client-8.0 //(2)安装mysql

sudo apt install php7.3 //(3)安装php
sudo apt install libapache2-mod-php7.3
sudo apt install php7.3-mysql

sudo service apache2 restart //(4)重启apache和mysql
sudo service mysql restart
//(5)浏览器访问方式:服务器IP地址

wget https://files.phpmyadmin.net/phpMyAdmin/5.0.1/phpMyAdmin-5.0.1-all-languages.tar.gz //(6)获取phpmyadmin文件
sudo ln -s /usr/share/phpmyadmin /var/www/html //文件解压并重命名为phpmyadmin,移动到/usr/share目录


sudo a2enmod rewrite //(7)启用Apache mod_rewrite
sudo systemctl restart apache2

文件添加如下内容: //(8)配置sudo vim /etc/apache2/apache2.conf
AddType application/x-httpd-php .php .htm .html
AddDefaultCharset UTF-8

sudo mysql -u root -p //(9)登录数据库
mysql> CREATE DATABASE wordpress; //创建数据库
mysql> FLUSH PRIVILEGES; //刷新数据库设置
mysql> exit //退出数据库


$sudo mysql -u root //修改用户root的密码,使用sudo登陆
mysql> USE mysql; //切换到mysql库
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit;
$sudo service mysql restart //重启mysql

$mysql -uroot -p //不使用sudo进入mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';//设置root用户的密码为root

wget https://cn.wordpress.org/latest-zh_CN.tar.gz //(10)安装wordpress
sudo rsync -avP ~/wordpress/ /var/www/html //解压后导入到服务器目录
cd /var/www/html //切换到wordpress目录
cp wp-config-sample.php wp-config.php //重命名为wp-config.php文件

sudo vim wp-config.php //(11)编辑wp-config.php文件

默认内容如下:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');
/** MySQL database username */
define('DB_USER', 'username_here');
/** MySQL database password */
define('DB_PASSWORD', 'password_here');
/** MySQL hostname */
define('DB_HOST', 'localhost');
将其修改为:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'root');
/** MySQL hostname */
define('DB_HOST', 'localhost');

服务器IP/wp-admin/install.php //(12)安装

服务器ip/wp-login.php //(13)登陆

apache2 端口路径:

1
sudo vi /etc/apach2/ports.conf

apache2 状态

1
sudo systemctl status apache2

apache2 重启

1
sudo systemctl restart apache2

web服务器安装成功后 , 就需设置一个简单明了的固定连接 , 查看下面的连接

permalinks 初期就应配置好

建站相关问题汇总,请点击下面的连接:

建站相关问题汇总