centos6.5下使用yum完美搭建LNMP环境(php5.6)
生活随笔
收集整理的這篇文章主要介紹了
centos6.5下使用yum完美搭建LNMP环境(php5.6)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
準備工作 配置防火墻,開啟80端口、3306端口 刪除原有的 iptables , 添加合適的配置 rm -rf /etc/sysconfig/iptablesvi /etc/sysconfig/iptables 添加如下內容 : ################################ 添加好之后防火墻
準備工作配置防火墻,開啟80端口、3306端口 添加如下內容 : ################################ 添加好之后防火墻規則如下所示################################ # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT #######################################################################################:wq保存退出, 重啟防火墻使配置生效 /etc/init.d/iptables restart關閉SELINUX rm -rf /etc/selinux/config vi /etc/selinux/config添加一行內容: SELINUX=disabled:wq保存退出 #重啟系統 shutdown -r now開始安裝一. 安裝nginx#刪除系統自帶的軟件包 yum remove httpd* php* #安裝nginx yum install -y nginx #設置nginx開機啟動 chkconfig nginx on #啟動nginx service nginx start二. 安裝PHP三. 安裝 MySQL配置1. 配置nginxrm -rf /etc/nginx/conf.d/* vi /etc/nginx/conf.d/default.conf添加如下內容 : server{listen 80;server_name _;index index.php index.html index.htm;root /var/www;location ~ .*\.(php|php5)?${#fastcgi_pass unix:/tmp/php-cgi.sock;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi.conf;}location / {try_files $uri $uri/ /index.php?$query_string;} }說明: /var/www 為web根目錄, location / ... 為url的rewrite,隱藏 index.php 2. 配置php-fpmvi /etc/php-fpm.d/www.conf將用戶和用戶組設置為nginx, 如: #修改用戶為nginx user = nginx#修改組為nginx group = nginx開始測試cd /var/www vi index.php添加以下代碼 <?php phpinfo(); ?>:wq! 保存退出 #設置權限 chown nginx.nginx /var/www -R #重啟nginx service nginx restart #重啟php-fpm service php-fpm restart在客戶端瀏覽器輸入服務器IP地址(如: 127.0.0.1),可以看到相關的配置信息! |
轉載于:https://my.oschina.net/u/593517/blog/805898
總結
以上是生活随笔為你收集整理的centos6.5下使用yum完美搭建LNMP环境(php5.6)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux 网卡信息查看
- 下一篇: PHP常用函数之文件系统处理