一、準備 Nginx + PHP 環境
1、安裝 Nginx
使用 yum 安裝 Nginx:
yum install nginx
2、修改 /etc/nginx/nginx.conf 文件爲如下內容:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name 127.0.0.1;
root /var/www/html;
index index.php index.html
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ .php$ {
root /var/www/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.ht {
deny all;
}
}
}
二、 啓動 Nginx 並設置爲開機啓動:
systemctl start nginx
systemctl enable nginx.service
三、安裝 PHP
1、使用 yum 安裝 php-fpm:
yum install php php-gd php-fpm php-mcrypt php-mbstring php-mysql php-pdo
2、啓動 php-fpm 並設置爲開機啓動:
systemctl start php-fpm
systemctl enable php-fpm.service
3、創建項目
下載安裝 Composer
Composer 是 PHP 的一個依賴管理工具,推薦使用 Composer 創建 ShowDoc 項目。
執行如下命令安裝 Compose:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
設置 Composer 使用國內鏡像
執行命令設置 Composer 使用國內鏡像:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
使用 Composer 創建項目
執行命令創建項目:
cd /var/www/html/ && composer create-project showdoc/showdoc
設置 showdoc 目錄寫權限
執行命令賦予 showdoc 下部分目錄的寫權限
chmod a+w showdoc/install
chmod a+w showdoc/Sqlite
chmod a+w showdoc/Sqlite/showdoc.db.php
chmod a+w showdoc/Public/Uploads/
chmod a+w showdoc/server/Application/Runtime
chmod a+w showdoc/server/Application/Common/Conf/config.php
chmod a+w showdoc/server/Application/Home/Conf/config.php
創建完畢,您現在可以通過瀏覽器訪問 http://119.29.239.104/showdoc/install/ ,進行語言的選擇以後即可通過 http://119.29.239.104/showdoc 查看站點效果。