centos7.3安裝php7.0

來源:互聯網
上載者:User

標籤:inux   query   htm   文章   php擴充   style   開啟   環境   word   

需求:在Centos7.3下搭建LNMP環境

文章轉載自:http://blog.csdn.net/wszll_alex/article/details/76285324 狂熱森林1. 關閉防火牆和selinux開啟檔案selinuxvim /etc/sysconfig/selinux將檔案中SELINUX=enforcing改為disabled,然後執行”setenforce 0″不用重啟地關閉selinux。SELINUX=disabled關閉放火牆systemctl stop firewalld.service 2.安裝軟體2.1.MYSQL安裝下載MySQL的repo源wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm安裝mysql-community-release-el7-5.noarch.rpm包rpm -ivh mysql-community-release-el7-5.noarch.rpm 安裝MYSQL? sudo yum install -y mysql-server? 更改MYSQL使用者權限:sudo chown -R root:root /var/lib/mysql? 重啟服務:systemctl restart mysql.service登入,並修改密碼:mysql -u rootmysql > use mysql;mysql > update user set password=password(‘123456‘) where user=‘root‘;mysql > exit;2.2nginx安裝下載對應當前系統版本的nginx包? wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm 建立nginx的yum倉庫(預設yum是沒有nginx的) rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm 下載並安裝nginx? yum install -y nginx nginx啟動? systemctl start nginx.service2.3安裝phprpm 安裝 Php7 相應的 yum源rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm安裝php7.0yum install -y php70w安裝PHP擴充yum install -y php70w-mysql.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64安裝php FPM? yum install -y php70w-fpm3. 修改設定檔3.1修改Nginx設定檔nginx設定檔位置:(/etc/nginx/conf.d/default.conf)vim /etc/nginx/conf.d/default.conf? 修改 root目錄,可自訂:root /forest/nginxDir/html;? 配置php解析,修改 下面代碼中黑色加粗部分: location ~.php$ { root /forest/nginxDir/html;? fastcgi_pass 127.0.0.1:9000;? fastcgi_index index.php; ?fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;? include fastcgi_params;? }3.2 修改php-fpm設定檔php-fpm設定檔位置:(/etc/php-fpm.d/www.conf)? 修改user =nginx? group=nginx4.放入測試檔案cd /forest/nginxDir/htmlecho ‘hello eric‘ >index.php5.啟動服務5.1啟動nginx服務:systemctl start nginx.service? 查看啟動狀態:systemctl status nginx 看到以下字眼說明啟動成功!?Active: active (running) since 六 2016-11-19 13:40:04 CST; 50min ago5.2.啟動PHP-FPM:systemctl start php-fpm.service? 查看啟動狀態:systemctl status php-fpm.service 看到以下字眼說明啟動成功!?Active: active (running) since 六 2016-11-19 14:14:33 CST; 18min ago6.測試在瀏覽器開啟192.168.44.129:80/index.php看到 hello eric 就大功告成~


設定開機自啟動服務
systemctl enable php-fpm.service
systemctl enable nginx.service


如項目架構為lavarel,則設定檔可用下面這個:
server {
listen 80;
server_name learn.laravel5.com;
root /var/www/html/learnlaravel5/public;
index index.html
index.php;
location / {
try_files $uri $uri/
/index.php$is_args$query_string;
}
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;
}
}

centos7.3安裝php7.0

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.