linux(centos7) nginx php mysql安裝

環境:php

linux:centos7html

php:7.0mysql

 

基礎命令linux

// yum install -y lrzsz // centos7 默認已安裝
yum install epel-releasenginx

 

nginx安裝sql

 1.依賴包centos

yum install gcc yum install pcre-devel yum install zlib zlib-devel yum install openssl openssl-devel //或者一鍵安裝上面四個依賴
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

2.下載http://nginx.org/api

3.配置、編譯與安裝php7

./configure \ --prefix=/usr/local/nginx \ --sbin-path=/usr/local/nginx/sbin/nginx \ --conf-path=/usr/local/nginx/conf/nginx.conf \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-pcre \ --lock-path=/var/run/nginx.lock \ --pid-path=/var/run/nginx.pid make && make install

 

4.關閉防火牆curl

  // 命令均可以

  service firewalld stop;
  systemctl stop firewalld.service;

// centos從7開始默認用的是firewalld,這個是基於iptables的,雖然有iptables的核心,可是iptables的服務是沒安裝的。因此你只要中止firewalld服務便可:
sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service

若是你要改用iptables的話,須要安裝iptables服務:
sudo yum install iptables-services
sudo systemctl enable iptables && sudo systemctl enable ip6tables
sudo systemctl start iptables && sudo systemctl start ip6tables

 

php安裝

1.下載http://www.php.net/downloads.php, 

2.安裝依賴

yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel curl

 

注意:安裝php7beta3的時候有幾處配置只是去,需要yum一下。現在php-7.0.2已經不用這樣了。
# yum -y install curl-devel
# yum -y install libxslt-devel

 

3.配置、編譯與安裝

./configure --prefix=/usr/local/php \ --with-curl \ --with-freetype-dir \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysqli \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql \ --with-pdo-sqlite \ --with-pear \ --with-png-dir \ --with-xmlrpc \ --with-xsl \ --with-zlib \ --enable-fpm \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-gd-native-ttf \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip

make && make install

 

./configure --prefix=/usr/local/php \ --with-curl \ --with-freetype-dir \ --with-gd \ --with-gettext \ --with-iconv-dir \ --with-kerberos \ --with-libdir=lib64 \ --with-libxml-dir \ --with-mysqli \ --with-openssl \ --with-pcre-regex \ --with-pdo-mysql \ --with-pdo-sqlite \ --without-pear  --disable-phar \ --with-png-dir \ --with-xmlrpc \ --with-xsl \ --with-zlib \ --enable-fpm \ --enable-bcmath \ --enable-libxml \ --enable-inline-optimization \ --enable-gd-native-ttf \ --enable-mbregex \ --enable-mbstring \ --enable-opcache \ --enable-pcntl \ --enable-shmop \ --enable-soap \ --enable-sockets \ --enable-sysvsem \ --enable-xml \ --enable-zip make && make install

 

若是報錯curl,則須要安裝

cd /down wget http://curl.haxx.se/download/curl-7.38.0.tar.gz
tar -xzvf curl-7.38.0.tar.gz cd tar -xzvf curl-7.38.0.tar.gz ./configure --prefix=/usr/local/curl make && make install

// yum安裝
yum install curl

 

 

配置文件

# cp php.ini-development /usr/local/php/lib/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
 
需要注意的是php7中www.conf這個配置文件配置phpfpm的端口號等信息,假設你改動默認的9000端口號需在這裏改,再改nginx的配置
啓動
#  /etc/init.d/php-fpm
 
配置nginx.conf
#location ~ \.php$ { 找到 # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} location ~ \.php$ { 改成 root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }

 

創建index.php 內容爲

<?php phpinfo() ?>

最後重啓

service nginx restart    或者./nginx -s reload  重啓nginx      

service php-fpm restart 或者 /etc/init.d/php-fpm  重啓 php-fpm

 

mysql安裝

 

其它知識

firewalld使用

啓動: systemctl start firewalld
關閉: systemctl stop firewalld
查看狀態: systemctl status firewalld 
開機禁用  : systemctl disable firewalld
開機啓用  : systemctl enable firewalld
相關文章
相關標籤/搜索