Linux服务配置 -- LAMP服务搭建

Linux服务配置 – LAMP服务搭建


title: LAMP安装和配置
categories:

  • Linux
  • Services
  • LAMP
    tags:
  • Linux
  • Services
  • LAMP
    abbrlink: 1609
    date: 2020-04-28 19:30:31
    src: 1.jpg

1. Apache安装

```bash
yum -y install httpd
vi /etc/httpd/conf/httpd.conf

# line 86: change to admin's email address
ServerAdmin root@locahost

# line 95: change to your server's name
ServerName ops.yeehnn.com:80

# line 151: change
AllowOverride All

# line 164: add file name that it can access only with directory's name
DirectoryIndex index.html index.cgi index.php

# add follows to the end
# server's response header
ServerTokens Prod

# keepalive is ON    保持http连接
KeepAlive On

firewall-cmd --add-service=http --permanent
firewall-cmd --reload
```
#### 以下暂时跳过
```bash
vi /etc/httpd/conf.d/vhost.conf

# create new
# for original domain
<VirtualHost *:80>
   DocumentRoot /var/www/html
   ServerName ops.yeehnn.com
</VirtualHost>

# for virtual domain
 <VirtualHost *:80>
   DocumentRoot /home/cent/public_html
   ServerName vhost.yeehnn.com
   ServerAdmin webmaster@virtual.host
   ErrorLog logs/virtual.host-error_log
   CustomLog logs/virtual.host-access_log combined
</VirtualHost>

systemctl restart httpd
```

2. MariaDB安装

```bash
yum -y install mariadb-server
vi /etc/my.cnf
# add follows within [mysqld] section
[mysqld]
character-set-server=utf8

systemctl start mariadb
systemctl enable mariadb
```
```bash
mysql_secure_installation
mysql -u root -p
select user,host,password from mysql.user;
show databases;

grant all on *.* to user@'localhost' identified by 'UserPassword';

firewall-cmd --add-service=mysql --permanent
firewall-cmd --reload
```

3. PHP安装

```bash
yum -y install php php-mbstring php-pear
vi /etc/php.ini

# line 878: uncomment and add your timezone
date.timezone = "Asia/Shanghai"

systemctl restart httpd
```
```bash
vi /var/www/html/phpinfo.php

<?php
phpinfo();
?>
```
```bash
vi ~/public_html/virtual.php
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Virtual Host Test Page
</div>
</body>
</html>
```
#### 扩展
```bash
yum -y install php-fpm
vi /etc/httpd/conf.d/php.conf

# line 5: change like follows
<FilesMatch \.php$>

# SetHandler application/x-httpd-php
    SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

systemctl start php-fpm
systemctl enable php-fpm
systemctl restart httpd

# http://ops.yeehnn.com/phpinfo.php
```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值