更新php
yum -y update
建立文件css
vim /etc/yum.repos.d/nginx.repo
文件內容,這配置是安裝最新的穩定版1.8html
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1
而後mysql
yum -y install nginx
檢查是否安裝成功nginx
systemctl start nginx
訪問你的ipweb
下載mysql的repo源sql
wget http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
安裝mysql-community-release-el7-7.noarch.rpm包vim
sudo rpm -Uvh mysql57-community-release-el7-7.noarch.rpm
安裝msyqlcentos
sudo yum install mysql-server
重啓mysqlphp-fpm
service mysqld restart
查看臨時密碼
sudo grep 'temporary password' /var/log/mysqld.log
修改密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewPass4!';
安裝Php和php 擴展
sudo yum install php php-mysql php-fpm php-mbstring php-gd php-pear php-mcrypt php-mhash php-eaccelerator php-cli php-
imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mssql php-snmp php-soap php-tidy php-common php-devel php-pecl-
xdebug -y
編輯php配置文件
sudo vi /etc/php.ini
cgi.fix_pathinfo=0
設置php-fpm配置文件
sudo vi /etc/php-fpm.d/www.conf
listen = /var/run/php-fpm/php-fpm.sock
啓動php-fpm服務
sudo systemctl start php-fpm
設置開機自動重啓php-fpm
sudo systemctl enable php-fpm.service
五.nginx配置
編輯站點配置文件
sudo vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name drupaluser.org;
root /opt/data;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
重啓nginx
sudo systemctl restart nginx
五.測試php腳本web服務
編輯測試文件
sudo vi /opt/data/info.php
<?php phpinfo()?>
訪問頁面,能看到php各類配置信息的話說明配置成功。
http://drupaluser.org/info.php
刪除測試文件
sudo rm /opt/data/info.php
到此CentOS 7下nginx,mysql,php安裝配置所有完成,能夠作爲web平臺的應用環境使用。
完成