manjaro linux 安装 Apache,MariaDB,PHP(LAMP)
root 身份执行下面的命令
1. 升级系统
pacman -Syu
2. 安装 Apache
升级完后,安装Apache
pacman -S apache
编辑 /etc/httpd/conf/httpd.conf file
nano /etc/httpd/conf/httpd.conf
# 我这里用的nano,你可用其它的编辑器只要能编辑文本就行
找到LoadModule unique_id_module modules/mod_unique_id.so 注释了
[...]
#LoadModule unique_id_module modules/mod_unique_id.so
[...]
保存退出
让Apache 开机启动 然后重启 Apache 服务
systemctl enable httpd
systemctl restart httpd
然后看看 Apache 服务是否启动成功
systemctl status httpd
Active: active (running) 有这个就意思成功运行
测试一下Apache
创建一个简单的页面
nano /srv/http/index.html
加入下列内容
<html>
<title>Welcome</title>
<body>
<h2> test page</h2>
</body>
</html>
3. 安装MariaDB
执行下列命令来安装
pacman -S mysql
然后执行下面的命令
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld
设置MySQL/MariaDB root user的密码
mysql_secure_installation
执行完后命令会出现下面的内容 按需选择
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
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.
Enter current password for root (enter for none): ## Press Enter
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n]## Press Enter
New password:## Enter password
Re-enter new password: ## Re-enter password
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.
Remove anonymous users? [Y/n]## Press Enter
... 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]## Press Enter
... Success!
By default, MariaDB 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]## Press Enter
- 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]## Press Enter
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
4. 安装 PHP
执行安装命令
pacman -S php php-apache
安装完后来编辑/etc/httpd/conf/httpd.conf文件
nano /etc/httpd/conf/httpd.conf
找到下面的行取消注释
[...]
#LoadModule mpm_event_module modules/mod_mpm_event.so
[...]
然后找到LoadModule mpm_prefork_module modules/mod_mpm_prefork.so 一般在刚刚注释的那行下买 没有就在下面加上 有的话就取消注释
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
然后在最后加上下面的几行
LoadModule php7_module modules/libphp7.so
AddHandler php7-script php
Include conf/extra/php7_module.conf
保存退出
测试php
创建test.php
nano /srv/http/test.php
加上下面几行
<?php
phpinfo();
?>
重启httpd service
systemctl restart httpd
然后打开http://ip-address/test.php
如果看到php的页面就成功
5 安装 phpMyAdmin
执行命令
pacman -S phpmyadmin php-mcrypt
安装完成后编辑php.ini
nano /etc/php/php.ini
取消下列行的注释
[...]
extension=bz2.so
extension=mcrypt.so
extension=mysqli.so
[...]
保存退出
编辑phpMyAdmin的配置文件
nano /etc/httpd/conf/extra/phpmyadmin.conf
加入下列内容
Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
<Directory "/usr/share/webapps/phpMyAdmin">
DirectoryIndex index.php
AllowOverride All
Options FollowSymlinks
Require all granted
</Directory>
编辑 Apache的配置文件
nano /etc/httpd/conf/httpd.conf
在最后加入
Include conf/extra/phpmyadmin.conf
保存,退出,重启httpd服务
systemctl restart httpd
测试phpMyAdmin
打开http://IP-Address/phpmyadmin
phpmyadmin测试
原文地址:https://www.cnblogs.com/bgst007/p/12321367.html
时间: 2024-11-05 16:00:44