CentOS 7 安装 LAMP

lisahost.com

1、清除、升级系统
yum clean all
yum -y update
hostname localhost
systemctl stop firewalld
systemctl disable firewalld

2、安装CSF
cd /usr/src
rm -fv csf.tgz
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh

3、配置CSF
nano /etc/csf/csf.conf

输入
csf -r

保存,退出。

4、更改OpenSSH默认端口(也可不做更改)
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
nano /etc/ssh/sshd_config
找到Port 22,更改为其他端口,并在CSF中放行。

保存,推出。
重启服务:
systemctl restart sshd.service

5、安装Apache

a、清除旧的服务:
yum -y install httpd

b、设置域名目录(把example.com改为自己的域名)
mkdir -p /var/www/example.com/public_html
chown -R $USER:$USER /var/www/example.com/public_html
chmod -R 755 /var/www
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled

c、编辑配置文件
nano /etc/httpd/conf/httpd.conf
把 IncludeOptional sites-enabled/*.conf 放到文件底部

d、保存,退出。
nano /etc/httpd/sites-available/example.com.conf

e、把以下添加到网站配置文件(把example.com改为自己的域名)

ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog /var/www/example.com/error.log
CustomLog /var/www/example.com/requests.log combined

f、保存,退出。
ln -s /etc/httpd/sites-available/example.com.conf /etc/httpd/sites-enabled/example.com.conf
apachectl restart

6、安装CertBot (使用lets-encrypt创建ssl证书)
yum install epel-release
yum install certbot
certbot certonly

下面是安装命令:
certbot renew –dry-run
certbot renew –quiet

7、安装PHP 5.6
yum -y update
yum -y install epel-release
wget https://dl.fedoraproject.org/pub/epe…t-7.noarch.rpm
wget https://centos7.iuscommunity.org/ius-release.rpm
rpm -Uvh ius-release*.rpm
yum -y update
yum -y install php56u php56u-opcache php56u-xml php56u-mcrypt php56u-gd php56u-devel php56u-mysql php56u-intl php56u-mbstring php56u-bcmath

8、安装MySQL
yum -y install mariadb-server mariadb
systemctl start mariadb
mysql_secure_installation

9、安装phpMyAdmin
yum -y install phpmyadmin
nano /etc/httpd/conf.d/phpMyAdmin.conf
把127.0.0.1改为你的独立IP
Alias /phpMyAdmin /usr/share/phpMyAdmin(把 /phpMyAdmin 改为 /usr/share/phpMyAdmin)

10、重启服务
systemctl restart httpd.service

via:http://www.webhostingtalk.com/showthread.php?t=1588551

    所有主机信息仅是为及时分享并收录,不做推荐!