sudo apt-get update
sudo apt-get install mysql-server php5-mysql在安装过程中,MySQL会要求您设置root密码。如果你错过了在程序安装时设置密码的机会,以后很容易从MySQL shell中设置密码。 一旦你安装了MySQL,我们应该用这个命令激活它:
sudo mysql_install_db通过运行MySQL设置脚本完成:
sudo /usr/bin/mysql_secure_installation提示将要求您输入当前的root密码。 输入。
Enter current password for root (enter for none): OK, successfully used password, moving on...然后提示将询问您是否要更改root密码。继续,选择N并继续下一步。 这是最简单只是说是的所有选项。最后,MySQL将重新加载和实现新的更改。
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...一旦你完成了,你可以通过安装PHP完成。
echo "deb http://ppa.launchpad.net/nginx/stable/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/nginx-stable.list sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C sudo apt-get update sudo apt-get install nginxnginx不会自己启动。要运行nginx,请输入:
sudo service nginx start您可以通过将浏览器定向到您的IP地址来确认nginx已安装了您的Web服务器。 您可以运行以下命令来显示您的VPS的IP地址。
ifconfig eth0 | grep inet | awk '{ print $2 }'
sudo apt-get install php5-fpm
sudo nano /etc/php5/fpm/php.ini找到行cgi.fix_pathinfo = 1,并将1更改为0。
cgi.fix_pathinfo=0如果这个数字保持为1,php解释器将尽最大努力来处理尽可能接近所请求的文件的文件。这是一种可能的安全风险。如果此数字设置为0,相反,解释器将只处理确切的文件路径 - 一个更安全的选择。保存并退出。我们需要在php5-fpm配置中进行另一个小的更改。打开www.conf:
sudo nano /etc/php5/fpm/pool.d/www.conf找到行,listen = 127.0.0.1:9000,并将127.0.0.1:9000更改为/var/run/php5-fpm.sock。
listen = /var/run/php5-fpm.sock保存并退出。 重新启动php-fpm:
sudo service php5-fpm restart
sudo nano /etc/nginx/sites-available/default配置应包括以下更改(更改的详细信息在配置信息下): 更新:较新的Ubuntu版本创建一个默认名称,而不是'WWW'“HTML”目录。如果/ usr / share / nginx / www不存在,它可能称为html。请确保正确更新配置。
[...] 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; } } [...]以下是更改的详细信息:
sudo nano /usr/share/nginx/www/info.php在以下行中添加:
<?php phpinfo(); ?>然后保存并退出。 重新启动nginx
sudo service nginx restart您可以访问http://youripaddress/info.php查看nginx和php-fpm配置详细信息 您的LEMP现在在您的虚拟专用服务器上设置和配置。
关注云架构公众号
Linux入门
QQ交流群:308781113