澳门威利斯人_威利斯人娱乐「手机版」

来自 办公软件 2019-06-22 11:20 的文章
当前位置: 澳门威利斯人 > 办公软件 > 正文

debug note-- nginx php-fpm : Error:The page you are looking

1.在ubuntu下安装配备nginx, mysql, php

原文:

今天抽空在Ali云上配置安装了PHP的条件

设置步骤:

LAMP is a combination of operating system and open-source software stack. The acronym LAMP came from the first letters ofLinux, Apache HTTP Server, MySQL or MariaDB database, and PHP/Perl/Python. This tutorial describes how to install LAMP stack on Ubuntu 16.04, however the steps described below should work on previous Ubuntu versions such as Ubuntu 15.10/15.04/14.10/14.04/13.10 etc.

主要有nginx, php5 php-fpm mysql phpmyadmin

参考:

Install LAMP Stack On Ubuntu 16.04

 

实际摘抄如下:

1. Install Apache

Apache is an open-source multi-platform web server. It provides a full range of web server features including CGI, SSL and virtual domains.

To install Apache, enter:

sudo apt-get install apache2

 

About Lemp

LEMP stack is a group of open source software to get web servers up and running. The acronym stands for Linux, nginx (pronounced Engine x), MySQL, and PHP. Since the server is already running Ubuntu, the linux part is taken care of. Here is how to install the rest.

Setup

The steps in this tutorial require the user to have root privileges. You can see how to set that up in the Initial Server Setup Tutorial in steps 3 and 4.

Step One—Update Apt-Get

Throughout this tutorial we will be using apt-get as an installer for all the server programs. On May 8th, 2012, a serious php vulnerability was discovered, and it is important that we download all of the latest patched software to protect the virtual private server.

Let's do a thorough update.

sudo apt-get update

Step Two—Install MySQL

MySQL is a powerful database management system used for organizing and retrieving data

To install MySQL, open terminal and type in these commands:

sudo apt-get install mysql-server php5-mysql

During the installation, MySQL will ask you to set a root password. If you miss the chance to set the password while the program is installing, it is very easy to set the password later from within the MySQL Shell.

Once you have installed MySQL, we should activate it with this command:

sudo mysql_install_db

Finish up by running the MySQL set up script:

sudo /usr/bin/mysql_secure_installation

The prompt will ask you for your current root password.

Type it in.

Enter current password for root (enter for none):   OK, successfully used password, moving on...

Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps.

It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.

By default, a MySQL installation has an anonymous user, allowing anyone  to log into MySQL without having to have a user account created for  them.  This is intended only for testing, and to make the installation  go a bit smoother.  You should remove them before moving into a  production environment.    Remove anonymous users? [Y/n] y                                               ... Success!    Normally, root should only be allowed to connect from 'localhost'.  This  ensures that someone cannot guess at the root password from the network.    Disallow root login remotely? [Y/n] y  ... Success!    By default, MySQL comes with a database named 'test' that anyone can  access.  This is also intended only for testing, and should be removed  before moving into a production environment.    Remove test database and access to it? [Y/n] y   - Dropping test database...   ... Success!   - Removing privileges on test database...   ... Success!    Reloading the privilege tables will ensure that all changes made so far  will take effect immediately.    Reload privilege tables now? [Y/n] y   ... Success!    Cleaning up...

Once you're done with that you can finish up by installing PHP.

Step Three—Install nginx

Once MySQL is all set up, we can move on to installing nginx on the VPS.

sudo apt-get install nginx

nginx does not start on its own. To get nginx running, type:

sudo service nginx start

You can confirm that nginx has installed an your web server by directing your browser to your IP address.

You can run the following command to reveal your VPS's IP address.

ifconfig eth0 | grep inet | awk '{ print $2 }'

Step Four—Install PHP

To install PHP-FPM, open terminal and type in these commands. We will configure the details of nginx and php details in the next step:

sudo apt-get install php5-fpm

Step Five—Configure php

We need to make one small change in the php configuration.Open up php.ini:

 sudo nano /etc/php5/fpm/php.ini

Find the line, cgi.fix_pathinfo=1, and change the 1 to 0.

cgi.fix_pathinfo=0

If this number is kept as 1, the php interpreter will do its best to process the file that is as near to the requested file as possible. This is a possible security risk. If this number is set to 0, conversely, the interpreter will only process the exact file path—a much safer alternative. Save and Exit. We need to make another small change in the php5-fpm configuration.Open up www.conf:

 sudo nano /etc/php5/fpm/pool.d/www.conf

Find the line, listen = 127.0.0.1:9000, and change the 127.0.0.1:9000 to /var/run/php5-fpm.sock.

listen = /var/run/php5-fpm.sock

Save and Exit.

Restart php-fpm:

sudo service php5-fpm restart

Step Six—Configure nginx

Open up the default virtual host file.

sudo nano /etc/nginx/sites-available/default

The configuration should include the changes below (the details of the changes are under the config information):

UPDATE: Newer Ubuntu versions create a directory called 'html' instead of 'www' by default. If /usr/share/nginx/www does not exist, it's probably called html. Make sure you update your configuration appropriately.

 [...]  server {          listen   80;                   root /usr/share/nginx/www;          index index.php index.html index.htm;            server_name example.com;            location / {                  try_files $uri $uri/ /index.html;          }            error_page 404 /404.html;            error_page 500 502 503 504 /50x.html;          location = /50x.html {                root /usr/share/nginx/www;          }            # pass the PHP scripts to FastCGI server listening on the php-fpm socket          location ~ .php$ {                  try_files $uri =404;                  fastcgi_pass unix:/var/run/php5-fpm.sock;                  fastcgi_index index.php;                  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                  include fastcgi_params;                            }    }  [...]

Here are the details of the changes:

  • Add index.php to the index line.
  • Change the server_name from local host to your domain name or IP address (replace the example.com in the configuration)
  • Change the correct lines in “location ~ .php$ {“ section

Save and Exit

Step Seven—Create a php Info Page

We can quickly see all of the details of the new php configuration.

To set this up, first create a new file:

sudo nano /usr/share/nginx/www/info.php

Add in the following line:

<?php  phpinfo();  ?>

Then Save and Exit.

Restart nginx

sudo service nginx restart

You can see the nginx and php-fpm configuration details by visiting

Your LEMP stack is now set up and configured on your virtual private server.

Enable  and  start   your  apache 
root@ubuntu:~# systemctl    enable  apache2
root@ubuntu:~# systemctl    start  apache2
root@ubuntu:~# systemctl    status  apache2
● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
   Active: active (running) since Wed 2016-03-02 09:23:37 PST; 1min 2s ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/apache2.service
           ├─22328 /usr/sbin/apache2 -k start
           ├─22331 /usr/sbin/apache2 -k start
           └─22332 /usr/sbin/apache2 -k start
Mar 02 09:23:36 ubuntu systemd[1]: Starting LSB: Apache2 web server...
Mar 02 09:23:36 ubuntu apache2[22304]:  * Starting web server apache2
Mar 02 09:23:36 ubuntu apache2[22304]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'S
Mar 02 09:23:37 ubuntu apache2[22304]:  *
Mar 02 09:23:37 ubuntu systemd[1]: Started LSB: Apache2 web server.
Mar 02 09:24:34 ubuntu systemd[1]: Started LSB: Apache2 web server.

本文来源:

 

Test Apache:

Open your web browser and navigate to  or .

图片 1

 

2. 服从上述小说介绍的安装步骤安装之后,通过浏览器访问php文件得到502页面:The page you are looking for is temporarily unavailable.

2. Install MySQL

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases, though SQLite probably has more total embedded deployments

sudo apt-get install mysql-server mysql-client

During installation, you’ll be asked to setup the MySQL “root” user password. Enter the password and click Ok.

图片 2

Re-enter the password.

图片 3

MySQL is installed now.

You can verify the MySQL server status using command:

On Ubuntu 16.04/15.10/15.04:

sudo systemctl status mysql

On Ubuntu 14.10 and previous versions:

sudo service mysql status

Sample output:

● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2015-10-26 14:23:01 IST; 28s ago
Main PID: 3577 (mysqld_safe)
CGroup: /system.slice/mysql.service
├─3577 /bin/sh /usr/bin/mysqld_safe
└─3924 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --...
Oct 26 14:23:00 server systemd[1]: Starting MySQL Community Server...
Oct 26 14:23:00 server mysqld_safe[3577]: 151026 14:23:00 mysqld_safe Can't ....
Oct 26 14:23:00 server mysqld_safe[3577]: 151026 14:23:00 mysqld_safe Loggin....
Oct 26 14:23:01 server mysqld_safe[3577]: 151026 14:23:01 mysqld_safe Starti...l
Oct 26 14:23:01 server systemd[1]: Started MySQL Community Server.
Hint: Some lines were ellipsized, use -l to show in full.

Since 3 years I’m completely into Nginx. For some reason I was always struggling with Apache, and that kept me from running my own server. But then a colleague told me about Nginx, and how great it was. So I looked into it, and the things I read were great. Compared to Apache, Nginx is smaller in size, it multiplies the performance remarkably by recducing the RAM and CPU usage for real time applications and it’s very flexible. Of course Apache will also have its advantages, but the fact I can’t come up with one says enough (about me, or Apache ;-)).

反省nginx的error.log文件: 开采错误:connect to php5-fpm.sock failed (Permission denied),

3. Install MariaDB

In case you want to use MariaDB instead of MySQL community edition, follow the steps given below.

MariaDB is a drop in replacement for MySQL. It is a robust, scalable and reliable SQL server that comes rich set of enhancements.

First you have to remove existing MySQL packages if any. To completely uninstall MySQL along with its configuration files, enter the following commands one by one:

sudo systemctl stop mysql

sudo apt-get remove --purge mysql-server mysql-client mysql-common

sudo apt-get autoremove

sudo apt-get autoclean

sudo rm -rf /var/lib/mysql/

sudo rm -rf /etc/mysql/

After removing MySQL, run the following command to install MariaDB.

sudo apt-get install mariadb-server

Alternatively, you can install it using MariaDB repository if you want to try most recent version of MariaDB. Run the following commands to add PPA. As of writing this, MariaDB PPA is not yet updated to Ubuntu 16.04. However, we can use the repository of Ubuntu 15.10 instead.

sudo apt-get install software-properties-common

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db

sudo add-apt-repository 'deb http://download.nus.edu.sg/mirror/mariadb/repo/10.1/ubuntu vivid main'

Update the software sources list and install MariaDB using following commands:

sudo apt-get update

sudo apt-get install mariadb-server

During installation you will be asked to set mysql ‘root’ user password. Enter the password twice, and complete the installation.

Important Note: In Ubuntu 16.04/15.10/15.04, MariaDB won’t ask you to set root user password during installation.

Also, you can’t set password manually using the following command too:

mysql_secure_installation

It will throw the following error.

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Enter current password for root (enter for none):

To fix this error, log in to mysql prompt without password as root user:

sudo mysql -u root

Then, run the following commands one by one in the mysql prompt:

use mysql;

update user set plugin='' where User='root';

flush privileges;

q

That’s it. Now, set database administrative “root” user password using command. Press Enter and go with the default settings.

mysql_secure_installation

Sample output:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): 
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] 
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] 
 ... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] 
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] 
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

Check if mariadb is running or not, using the following command:

sudo service mysql status

Sample output:

● mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql)
 Active: active (running) since Mon 2015-10-26 14:26:36 IST; 2min 5s ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/mysql.service
├─6387 /bin/bash /usr/bin/mysqld_safe
├─6388 logger -p daemon err -t /etc/init.d/mysql -i
└─6544 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --...
Oct 26 14:26:39 server /etc/mysql/debian-start[6595]: mysql.time_zone_transit...
Oct 26 14:26:39 server /etc/mysql/debian-start[6595]: mysql.time_zone_transit...
Oct 26 14:26:39 server /etc/mysql/debian-start[6595]: mysql.user ...
Oct 26 14:26:39 server /etc/mysql/debian-start[6595]: Phase 2/6: Fixing views
Oct 26 14:26:39 server /etc/mysql/debian-start[6595]: Processing databases
Oct 26 14:26:39 server /etc/mysql/debian-start[6595]: information_schema
Oct 26 14:26:39 server /etc/mysql/debian-start[6595]: mysql
Oct 26 14:26:39 server /etc/mysql/debian-start[6595]: performance_schema
Oct 26 14:26:39 server /etc/mysql/debian-start[6653]: Checking for insecure r...
Oct 26 14:26:39 server /etc/mysql/debian-start[6657]: Triggering myisam-recov...
Hint: Some lines were ellipsized, use -l to show in full.

So today I’m going to show you how to setup Nginx with PHP 5 and MySQL on Ubuntu 12.04. It’s really not that difficult. Let’s start with Nginx.

反省php5-fpm.sock的权柄获得other的权能为:---

4. Install PHP  (PHP7)

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely used open-source general purpose scripting language that is especially suited for web development and can be embedded into HTML.

Install PHP with following command:

sudo apt-get update 
sudo apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi  php7.0 libapache2-mod-php7

Test  your php version

root@ubuntu:~# php -v
PHP 7.0.3-3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
root@ubuntu:~#

To test PHP, create a sample “testphp.php” file in Apache document root folder.

sudo vi  /var/www/html/testphp.php

Add the following lines:

<?php
phpinfo();
?>

Restart apache2 service.

On Ubuntu 15.10/15.04:

sudo systemctl restart apache2

On Ubuntu 14.10 and lower versions:

sudo service apache2 restart

Navigate to . It will display all the details about php such as version, build date and commands etc.

图片 4

If you want to install all php modules at once, enter the command sudo apt-get install php* and restart the apache2 service. To verify the modules, open web browser and navigate to . You will able to see all installed php modules.

1
sudo apt-get install nginx -y

化解方法:

5. Manage MySQL Databases (Optional)

That’s it. But now we want to configure Nginx. I normally use Sublime Text 2 as a text editor, because VI hates me (or I hate VI, really hard to tell). But on a remote server sublime is not really an option, so I will just use nano. Feel free to use the editor you prefer.

参考:

Install phpMyAdmin

phpMyAdmin is a free open-source web interface tool used to manage your MySQL databases. It is available in the Official Debian repositories. So install it with command:

sudo apt-get install phpmyadmin

Select the Web server that should be automatically configured to run phpMyAdmin. In my case, it is apache2.

图片 5

The phpMyAdmin must have a database installed and configured before it can be used. This can be optionally handled by dbconfig-common.

Select ‘Yes’ to configure database for phpmyadmin wjth dbconfig-common.

图片 6

Enter password of the database’s administrative user.

图片 7

Enter MySQL application password for phpmyadmin:

图片 8

Re-enter password:

图片 9

Success! phpMyAdmin installation is installed.

Additional Note: if you followed all steps carefully, phpMyAdmin should work just fine. In case phpMyAdmin is not working, please do the following steps.

Open terminal, and type:

sudo nano /etc/apache2/apache2.conf

Add the following line at the end.

Include /etc/phpmyadmin/apache.conf

Save and Exit. Restart apache service:

On Ubuntu 16.04/15.10/15.04:

sudo systemctl restart apache2

On Ubuntu 14.10 and lower versions:

sudo /etc/init.d/apache2 restart

You can download the config here.

具体摘抄如下:

6. Access phpMyAdmin Web Console

Now, you can access the phpmyadmin console by navigating to  from your browser.

Enter your MySQL username and password which you have given in previous steps. In my case its “root” and “ubuntu”.

图片 10

You will be redirected to PhpMyAdmin main web interface.

图片 11

From here, you can manage your MySQL databases from phpMyAdmin web interface.

That’s it. Your LAMP stack is ready to use.

1
2
3
cd /etc/nginx
sudo cp nginx.conf nginx.conf.backup
sudo nano nginx.conf
  1. Open /etc/php5/fpm/pool.d/www.conf
  2. Uncomment all permission lines, like:

    listen.owner = www-data  listen.group = www-data  listen.mode = 0660  
    
  3. Restart fpm - sudo service php5-fpm restart

     Note: if your webserver runs as as user other than www-data, you will need to update the www.conf file accordingly

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
user www-data;
 
# As a thumb rule: One per CPU. If you are serving a large amount
# of static files, which requires blocking disk reads, you may want
# to increase this from the number of cpu_cores available on your
# system.
#
# The maximum number of connections for Nginx is calculated by:
# max_clients = worker_processes * worker_connections
worker_processes 1;
 
# Maximum file descriptors that can be opened per process
# This should be > worker_connections
worker_rlimit_nofile 8192;
 
events {
    # When you need > 8000 * cpu_cores connections, you start optimizing
    # your OS, and this is probably the point at where you hire people
    # who are smarter than you, this is *a lot* of requests.
    worker_connections 8000;
}
 
error_log /var/log/nginx/error.log;
 
pid /var/run/nginx.pid;
 
http {
    charset utf-8;
 
    # Set the mime-types via the mime.types external file
    include mime.types;
 
    # And the fallback mime-type
    default_type application/octet-stream;
 
    # Click tracking!
    access_log /var/log/nginx/access.log;
 
    # Hide nginx version
    server_tokens off;
 
    # ~2 seconds is often enough for HTML/CSS, but connections in
    # Nginx are cheap, so generally it's safe to increase it
    keepalive_timeout 20;
 
    # You usually want to serve static files with Nginx
    sendfile on;
 
    tcp_nopush on; # off may be better for Comet/long-poll stuff
    tcp_nodelay off; # on may be better for Comet/long-poll stuff
 
    server_name_in_redirect off;
    types_hash_max_size 2048;
 
    gzip on;
    gzip_http_version 1.0;
    gzip_comp_level 5;
    gzip_min_length 512;
    gzip_buffers 4 8k;
    gzip_proxied any;
    gzip_types
        # text/html is always compressed by HttpGzipModule
        text/css
        text/plain
        text/x-component
        application/javascript
        application/json
        application/xml
        application/xhtml xml
        application/x-font-ttf
        application/x-font-opentype
        application/vnd.ms-fontobject
        image/svg xml
        image/x-icon;
 
    # This should be turned on if you are going to have pre-compressed copies (.gz) of
    # static files available. If not it should be left off as it will cause extra I/O
    # for the check. It would be better to enable this in a location {} block for
    # a specific directory:
    # gzip_static on;
 
    gzip_disable "msie6";
    gzip_vary on;
 
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

Change the default site config. You can download the config here.

1
2
sudo cp sites-available/default sites-available/default.backup
sudo nano sites-available/default
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
server {
    listen 80 default; ## listen for ipv4; this line is default and implied
    listen [::]:80 default ipv6only=on; ## listen for ipv6
 
    # Make site accessible from http://localhost/ or server IP-address
    server_name localhost;
    server_name_in_redirect off;
 
    charset utf-8;
 
    access_log /usr/share/nginx/access.log;
    error_log /usr/share/nginx/error.log;
 
    root /usr/share/nginx/www;
    index index.php index.html index.htm;
 
    location / {
        # First attempt to serve request as file, then
        # as directory, then trigger 404
        try_files $uri $uri/ =404;
    }
}

Now we need to reload Nginx.

本文由澳门威利斯人发布于办公软件,转载请注明出处:debug note-- nginx php-fpm : Error:The page you are looking

关键词: 澳门威利斯人 linux