适用于有洁癖、重视安全的人。一般建议使用:OneinStack:自助安装lnmp、lamp、lnmpa等(支持HHVM)
建议CentOS 7.均为SSH下、root用户。
一、升级系统,更换更新源
适用于CentOS / RHEL 7系统
yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
适用于CentOS / RHEL 6系统
yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
二、安装PHP 7
1、安装PHP 7
yum install php70w
2、安装PHP 7组件
查找组件
yum search php70w
安装组件
yum install php70w-mysql php70w-xml php70w-soap php70w-xmlrpc
yum install php70w-mbstring php70w-json php70w-gd php70w-mcrypt
三、安装NGINX
1、安装NGINX
yum install nginx
2、启动NGINX
systemctl enable nginx.service
systemctl start nginx.service
四、安装MySQL 5.6
1、安装MySQL
yum install mysql-server
2、安全设置
systemctl start mysqld.service
mysql_secure_installation
3、启动MySQL
systemctl restart mysqld.service
systemctl enable mysqld.service
五、设置PHP-FPM
yum install php70w-fpm
六、创建网站
nano /etc/nginx/conf.d/example.conf
粘贴如下内容:
server {
listen 80;
root /var/www;
index index.php index.html index.htm;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
根据需要更改为自己的域名、文件存放目录。
七、重启服务
systemctl restart nginx.service
systemctl restart php-fpm.service
八、防火墙开放http (80) 和 https (443)端口
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload