Home Backend Development PHP Tutorial 阿里云服务器cent0S安装web环境PHP+MySql+Nginx,给nginx添加网站

阿里云服务器cent0S安装web环境PHP+MySql+Nginx,给nginx添加网站

Jun 23, 2016 pm 01:41 PM

下载一键安装包:

http://market.aliyun.com/product/12-121590002-cmgj000262.html?spm=5176.7150518.1996836753.5.ZoE32o


在服务器安装rz命令

yum install lrzsz


rz    选择要上传文件sh.zip


安装解压命令:

yum install unzip    #本机已经安装了.所以这里不安装

解压

unzip -x sh.zip    #解压后脚本的权限不够

chmod -R 755 sh    #-R 递归将目录里面所有文件权限都改为755


在sh目录下执行

./install.sh


安装完毕后,检查

ps -ef|grep nginx

ps -ef|grep mysql


在sh目录下执行

cat account.log    #查看mysql账号密码

FTP:

account:www

password:zzzzzz

MySQL:

account:root

password:zzzzzz


netstat -nat    #查看3306端口有没有listen

rpm -q mysql     #查询发现是mysql-server没有安装

yum install mysql-server    #安装mysql-server服务

service mysqld restart


mysql                #查看mysql信息

mysql -p3306 -u用户名 -p密码    #登录mysql

mysql -p3306 -uroot -pzzzzzzz

use mysql    #进入mysql这个数据库

show tables

desc user

select Host,User,Password from user;    #查看数据库用户

exit    #退出

mysql -p3306 -u用户名 -p密码    #登录mysql

use mysql

update user set Host='%' where Host='localhost'    #%表示任意的,这样就可以在其他电脑连接ip

flush privileges    #刷新


在外部电脑:

浏览器输入:服务器ip        # 对phpwind进行设置


Nginx添加网站:


在服务器目录:    /alidata/server    有下面目录:

mysql  mysql-5.6.21  nginx  nginx-1.4.4  php  php-5.5.7


进入目录:    /alidata/server/nginx/conf

cat nginx.conf    #这个文件找到最后一行

include /alidata/server/nginx/conf/vhosts/*.conf;

#包含了vhosts下面所有配置文件,一个网站一个conf


进入目录:alidata/server/nginx/conf/vhosts/

查看文件:    cat phpwind.conf

文件开始:::::

server {

        listen       80;

        server_name  localhost;        #这里localhost,所以浏览器输入ip可以访问,如果输入www.xxx.com,浏览器就只能输入相关域名

        index index.html index.htm index.php;

        root /alidata/www/phpwind;

        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 ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

        {

                expires 30d;

        }

        location ~ .*\.(js|css)?$

        {

                expires 1h;

        }

        #伪静态规则

        include /alidata/server/nginx/conf/rewrite/phpwind.conf;

        access_log  /alidata/log/nginx/access/phpwind.log;


文件结束:::::::::


添加站点:www.paidaxue.com


cp default.conf.bak paidaxue.conf

修改文件:vim  paidaxue.conf

 修改:    server_name  localhost;

修改为:

 server_name  www.paidaxue.com;

修改:    root /alidata/www/phpwind;

修改为:

root /alidata/www/paidaxue.com; 


修改:        如果原来没有这一段就忽略修改

log_farmat aliyun '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

' "$http_user_agent" "$http_x_forwarded_for"';

修改为:

log_farmat paidaxue '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

' "$http_user_agent" "$http_x_forwarded_for"';


修改:

access_log  /alidata/log/nginx/access/default.log;

修改为:

access_log  /alidata/log/nginx/access/paidaxue.com;


保存


进入目录:

/alidata/server/nginx/sbin/nginx -s reload          #重启nginx


浏览器输入:www.paidaxue.com    #会显示404not found    因为没有对应目录


新建目录: alidata/www/paidaxue.com

mkdir -p /alidata/www/paidaxue.com


查看新建的目录:        #paidaxue.com是在root的用户,root用户组中

drwxr-xr-x  2 root root 4096 Jan 13 17:00 paidaxue.com

drwxr-xr-x 26 www  www  4096 Jan 13 16:15 phpwind


浏览器输入:www.paidaxue.com    #会显示403Forbidden    因为没有权限访问

所以要对 paidaxue.com的权限进行更改,变成和下面一样的www

cd /alidata/www/


chown -R www:www /alidata/www/paidaxue.com

浏览器输入:www.paidaxue.com    #会显示403Forbidden    因为里面没有文件

cd /alidata/www/paidaxue.com

在上面文件夹新建index.html    

浏览器输入:www.paidaxue.com    #正常

 




Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

See all articles